[Matplotlib-users] TkAgg won't plot - how to debug?

Andrew Z formisc at gmail.com
Wed Nov 8 16:41:07 EST 2017


I tried PyQT5 with the same unhappy results:

First, i  verified that pyqt5 works -

PyQt5 (5.9.1)                     - Python bindings for the Qt cross
platform UI and application toolkit
  INSTALLED: 5.9
  LATEST:    5.9.1

ran http://www.thehackeruniversity.com/2014/01/23/pyqt5-beginner-tutorial/
-  exampled worked with no issues. Everything got resolved in pycharm.

next installed the matplot backend:
   python3-matplotlib-qt5.x86_64

ran examples from here https://pythonspot.com/en/pyqt5-matplotlib/ - and it
hanged.
pycharm is complaining about :

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.pyplot as plt

"can not find reference 'backends' in __init__.py'
' unresolved reference backend_qt5agg'
'cant reference 'figure' '
'no module named pyplot'





On Mon, Nov 6, 2017 at 6:33 PM, Andrew Z <formisc at gmail.com> wrote:

> this is what i have installed:
> [az at hp src]$ rpm -qa | grep tkint
> python3-tkinter-3.5.3-6.fc24.x86_64
> tkinter-2.7.13-2.fc24.x86_64
> [az at hp src]$
>
>
> [az at hp src]$ pip3 list | grep tk
> DEPRECATION: The default format will switch to columns in the future. You
> can use --format=(legacy|columns) (or define a format=(legacy|columns) in
> your pip.conf under the [list] section) to disable this warning.
>
>
> rpm -qa | grep matplot
> python-matplotlib-data-fonts-1.5.2-0.1.rc2.fc24.noarch
> python3-matplotlib-1.5.2-0.1.rc2.fc24.x86_64
> python3-matplotlib-tk-1.5.2-0.1.rc2.fc24.x86_64
> python-matplotlib-data-1.5.2-0.1.rc2.fc24.noarch
>
> basically i removed the pip3 installed matplot and felt back to rpm
> provided in hope to have that config working.
>
> Copy/paste from https://matplotlib.org/gallery/pyplots/pyplot_simple.
> html#sphx-glr-gallery-pyplots-pyplot-simple-py
> [az at hp src]$ which python3.5
> /usr/bin/python3.5
> [az at hp src]$ file /usr/bin/python3.5
> /usr/bin/python3.5: ELF 64-bit LSB shared object, x86-64, version 1
> (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for
> GNU/Linux 2.6.32, BuildID[sha1]=cc90b759ab34ba1043b3a96779f17eba4c0baf7a,
> stripped
> [az at hp src]$
> [az at hp src]$ python3.5
> Python 3.5.3 (default, May 11 2017, 09:10:41)
> [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib.pyplot as plt
> >>> plt.plot([1,2,3,4])
> <hangs with one core 100% busy>
> Terminated
> [az at hp src]$
> [az at hp src]$
> [az at hp src]$ python3.5
> Python 3.5.3 (default, May 11 2017, 09:10:41)
> [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib.pyplot as plt
> >>> import matplotlib
> >>> matplotlib.get_backend()
> 'TkAgg'
> >>> exit
> Use exit() or Ctrl-D (i.e. EOF) to exit
>
> removing TKagg from config:
> [az at hp src]$ find / -name matplotlibrc* 2>>/dev/null
> /etc/matplotlibrc
> [az at hp src]$ grep -v ^# /etc/matplotlibrc
> backend      : TkAgg
>
> changing to Agg and running the same code:
>
> [az at hp src]$ python3.5
> Python 3.5.3 (default, May 11 2017, 09:10:41)
> [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib
> >>> matplotlib.get_backend()
> 'agg'
> >>> import matplotlib.pyplot as plt
> >>> plt.ylabel('some numbers')
> ^C^Z
> [1]+  Stopped                 python3.5
>
> [az at hp src]$ python3.5
> Python 3.5.3 (default, May 11 2017, 09:10:41)
> [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib.pyplot as plt
> >>> plt.plot([1,2,3,4])
> <Hangs>
>
> I'll stop making any changes to the env now, since i don't want to bring
> any confusion into the matter.
> thank you for helping out!
>
>
>
>
>
>
>
>
> On Mon, Nov 6, 2017 at 4:48 PM, Andrew Z <formisc at gmail.com> wrote:
>
>>
>> >backend in your matplotlibrc file to "agg" and it still hung on you?
>>
>> Yes. I can confirm that
>>
>> >Some possibilities are
>> >...."matplotlib.py" or "pylab.py" or some such, and then start to wonder
>> why their code doesn't work properly.
>>
>> I used pycharms "scratch files" and typed directly in the interpreter-
>> always same result. I saw this naming issue whileresearching my problem. My
>> file is plot.py and works perfectly fine on any other machine but
>> this.(drives me mad, honestly). Directory is /home/az/work/nja/src. Also
>> consistent across machines (minus username)
>>
>> >Have you looked to see if there are other programs that are running
>> during the import stage?
>>
>> Im not sure what do you mean?
>> I have a xwindow terminal , nothing but Firefox is up.(well a tons of
>> regular background processes).
>>
>>
>>
>>
>> On Nov 6, 2017 16:18, "Benjamin Root" <ben.v.root at gmail.com> wrote:
>>
>>> Just to make absolutely clear, you set the default backend in your
>>> matplotlibrc file to "agg" and it still hung on you? If that is the case,
>>> then the problem isn't tkinter.
>>>
>>> Some possibilities are
>>>
>>> 1) a massive font database that matplotlib is trying to build a cache for
>>> 2) import of matplotlib from somewhere else unexpected (which would
>>> explain pycharm's behavior), and that file/module is misbehaving. We have
>>> seen instances in the past where users would name their plotting porting of
>>> their code "matplotlib.py" or "pylab.py" or some such, and then start to
>>> wonder why their code doesn't work properly.
>>>
>>> Have you looked to see if there are other programs that are running
>>> during the import stage? One thing matplotlib does for the first import is
>>> to create a font cache, and it does this by using some fc-list program,
>>> iirc. This can take a long time on some machines that have adobe's font
>>> collection installed, for example, but that is usually a Windows thing....
>>>
>>> Ben Root
>>>
>>>
>>> On Mon, Nov 6, 2017 at 4:09 PM, Andrew Z <formisc at gmail.com> wrote:
>>>
>>>> Tkinter was most likely installed as part of rpm install.
>>>> Backends - not really. I do know that with mpld3and agg  the scripts
>>>> hang.
>>>> Ihave reinstalled matplot using rpm ( rpm comes only in 1.5 version)
>>>> and with pip3.
>>>> Today i tried on the office machine (fedora 25). Rpm brings only
>>>> matplot1.5.
>>>>
>>>> maybe 2 installed locally using pip3 messes with 1.5 leftover or
>>>> libraries.
>>>> Not sure how to validate this idea though..
>>>> Probably unrelated:
>>>> In pycharm pyplot is not been recognized as part of matplotlib when i
>>>> "import matplotlib.pyplot. yet the script doesnt crash on import
>>>> statement...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Nov 6, 2017 15:13, "Benjamin Root" <ben.v.root at gmail.com> wrote:
>>>>
>>>> How did you install Tkinter? Have you tested any other backends? Does
>>>> this happen for just the head-less "Agg" backend set as default?
>>>>
>>>> On Sat, Nov 4, 2017 at 3:35 PM, Andrew Z <formisc at gmail.com> wrote:
>>>>
>>>>> more relevant information:
>>>>> [az at hp src]$ python3.5
>>>>> Python 3.5.3 (default, May 11 2017, 09:10:41)
>>>>> [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
>>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> >>> import matplotlib
>>>>> >>> matplotlib.__file__
>>>>> '/home/az/.local/lib/python3.5/site-packages/matplotlib/__init__.py'
>>>>> >>> matplotlib.get_configdir()
>>>>> '/home/az/.config/matplotlib'
>>>>> >>> print(matplotlib.__version__)
>>>>> 2.1.0
>>>>>
>>>>> now if i get the simplest plot :
>>>>>
>>>>> [az at hp src]$ more ./main1.py
>>>>> import matplotlib.pyplot as plt
>>>>> print("imported")
>>>>> plt.plot([1,2,4,1])
>>>>> print("plot is done")
>>>>> plt.show()
>>>>> print("show is done")
>>>>>
>>>>> [az at hp src]$ python3.5 main1.py --verbose-debug
>>>>> $HOME=/home/az
>>>>> matplotlib data path /home/az/.local/lib/python3.5/
>>>>> site-packages/matplotlib/mpl-data
>>>>> loaded rc file /home/az/.local/lib/python3.5/
>>>>> site-packages/matplotlib/mpl-data/matplotlibrc
>>>>> matplotlib version 2.1.0
>>>>> verbose.level debug
>>>>> interactive is False
>>>>> platform is linux
>>>>> loaded modules: ['_locale', 'urllib.request', 'numpy.lib.shape_base',
>>>>> 'numpy.matrixlib', 'ipaddress', 'hashlib', 'collections',
>>>>> 'numpy.lib.financial', 'atexit', 'numpy.lib._iotools',
>>>>> '_frozen_importlib_external', 'numpy.polynomial.chebyshev', 'six',
>>>>> 'unittest.runner', '_sitebuiltins', 'numpy.compat', 'numpy.ma.core',
>>>>> 'abrt_exception_handler3', 'codecs', 'sre_constants', 'calendar',
>>>>> 'matplotlib.cbook', 'contextlib', 'heapq', 'ssl', 'dis', 'binascii',
>>>>> 'posixpath', 'cython_runtime', 'traceback', 'numpy.polynomial.laguerre',
>>>>> '_hashlib', 'zipimport', 'email.utils', '_functools', 'copyreg', 'sys',
>>>>> '_sre', 'matplotlib.cbook._backports', 'numpy.lib.arraysetops', 'random',
>>>>> 'email.parser', 'numpy.fft.helper', '_collections', 'difflib',
>>>>> 'numpy.lib.scimath', 'unittest', '_sysconfigdata', 'numpy', 'site', '_ast',
>>>>> 'json.scanner', 'os', 'http', 'functools', 'unittest.main', '
>>>>> numpy.linalg.info', '_heapq', 'token', 'pathlib', 'tokenize',
>>>>> 'cycler', 'encodings.cp437', 'numpy.polynomial.polynomial',
>>>>> 'numpy.polynomial._polybase', 'numpy.lib.mixins', 'ctypes._endian',
>>>>> 'numpy.lib.arraypad', 'numpy.matrixlib.defmatrix', 'distutils.version',
>>>>> '_signal', 'marshal', 'stat', 'pprint', 'base64', 'logging', 'enum',
>>>>> 'selectors', 'numpy.core', 'json.encoder', 'operator',
>>>>> 'numpy.testing.nosetester', 'matplotlib._version', 'numpy.ctypeslib',
>>>>> 'numpy.add_newdocs', 'unittest.util', '_weakref', 'select',
>>>>> 'importlib._bootstrap_external', 'mtrand', 'importlib._bootstrap',
>>>>> 'matplotlib.rcsetup', 'matplotlib.colors', 'numpy.testing.decorators',
>>>>> 'json', 'numpy.core.machar', 'email.encoders', 'six.moves.urllib',
>>>>> 'matplotlib', 'keyword', 'errno', 'numpy.lib.stride_tricks', '_socket',
>>>>> 'email.quoprimime', 'numpy.ma.extras', 'numbers', 'numpy.version',
>>>>> '_bisect', '_string', 'numpy.lib.arrayterator', 'numpy.core.umath',
>>>>> 'numpy.lib', '_thread', 'time', '_frozen_importlib', 'numpy.core.info',
>>>>> 'numpy.core.multiarray', 'math', '_opcode', 'urllib.parse',
>>>>> 'distutils.sysconfig', 'ntpath', 'argparse', 'types', 'sre_compile',
>>>>> 'glob', '__main__', 'email._encoded_words', 'socket', '_struct', '
>>>>> numpy.fft.info', 'unittest.signals', 'numpy.lib.npyio', 'grp',
>>>>> 'urllib.error', '_io', 'numpy._globals', 'gettext', 'numpy.compat.py3k',
>>>>> 'distutils', 'email.charset', 'ast', 'numpy.lib.function_base', 'uu',
>>>>> 'encodings', 'urllib', 'numpy.lib.twodim_base', 'encodings.latin_1',
>>>>> 'tempfile', 'numpy.lib._version', 'numpy.polynomial.polyutils', 'quopri',
>>>>> 'os.path', '_imp', 'email.base64mime', 'email.message', 'email.header',
>>>>> 'opcode', 'encodings.utf_8', 'reprlib', '_stat', '_warnings',
>>>>> 'email.feedparser', 'numpy.testing.utils', 'numpy.lib.utils',
>>>>> 'genericpath', 'numpy.polynomial.hermite', '_compat_pickle', 'bz2',
>>>>> '_compression', 'subprocess', '_json', 'numpy.lib.nanfunctions', 'inspect',
>>>>> 'sysconfig', '_operator', 'shutil', 'pwd', 'warnings', '_ctypes',
>>>>> '_random', 'email.iterators', '_collections_abc', '__future__', 'email',
>>>>> 'numpy._distributor_init', 'unittest.loader', '_bootlocale',
>>>>> 'numpy.core.records', 'fnmatch', '_posixsubprocess', 'numpy._import_tools',
>>>>> 'numpy.lib.format', '_lzma', 'numpy.core.arrayprint', 'json.decoder',
>>>>> 'signal', 'gzip', 'posix', 'textwrap', 'numpy.fft.fftpack',
>>>>> 'importlib.machinery', 'lzma', 'struct', 'pickle', '_codecs',
>>>>> 'numpy.core.einsumfunc', 'itertools', 'numpy.core.shape_base',
>>>>> 'encodings.aliases', 'numpy.lib.index_tricks', 'numpy.random.info',
>>>>> 'numpy.linalg._umath_linalg', 'matplotlib.fontconfig_pattern',
>>>>> 'six.moves.urllib.request', '_weakrefset', 'distutils.errors', 'io',
>>>>> 'locale', 'email.errors', 'numpy.core.numerictypes',
>>>>> 'numpy.compat._inspect', 'zlib', 'numpy.polynomial.hermite_e',
>>>>> 'numpy.lib.type_check', 'mpl_toolkits', 'numpy.fft.fftpack_lite', 'bisect',
>>>>> 'dateutil', 'numpy.polynomial', 'collections.abc', '_bz2', 'weakref',
>>>>> 'numpy.lib.ufunclike', 'numpy.core.function_base', 'abc', 'six.moves',
>>>>> 'numpy.linalg', 'numpy.polynomial.legendre', 'numpy.core.defchararray',
>>>>> 'numpy.linalg.lapack_lite', 'numpy.core._internal', 'importlib',
>>>>> 'unittest.suite', 'unittest.case', 'numpy.core.memmap', 'email._parseaddr',
>>>>> '_pickle', '_ssl', 'matplotlib.compat.subprocess', 'numpy.random',
>>>>> 'datetime', 'email._policybase', 'sre_parse', 'numpy.linalg.linalg',
>>>>> 'copy', 'numpy.lib._datasource', 'numpy.core._methods', 'linecache',
>>>>> 'matplotlib.compat', 'numpy.testing', 'numpy.__config__',
>>>>> 'unittest.result', 're', 'http.client', 'numpy.lib.info',
>>>>> 'numpy.core.fromnumeric', 'numpy.core.getlimits', 'matplotlib._color_data',
>>>>> 'urllib.response', 'pyparsing', 'numpy.lib.polynomial', 'threading',
>>>>> 'string', 'numpy.core.numeric', 'numpy.ma', 'numpy.fft', 'ctypes',
>>>>> 'numpy.random.mtrand', 'matplotlib.cbook.deprecation', '_datetime',
>>>>> 'builtins']
>>>>> CACHEDIR=/home/az/.cache/matplotlib
>>>>> Using fontManager instance from /home/az/.cache/matplotlib/fon
>>>>> tList.json
>>>>> backend TkAgg version 8.6
>>>>> imported
>>>>> ^C
>>>>> Hangs at this point with CPU @ 100%
>>>>>
>>>>> grep -v '#' /home/az/.local/lib/python3.5/
>>>>> site-packages/matplotlib/mpl-data/matplotlibrc
>>>>>
>>>>> The only line is :
>>>>> backend      : TkAgg
>>>>>
>>>>>
>>>>> [az at hp src]$ gcc --version
>>>>> gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
>>>>>
>>>>> I installed using pip3 into --user directory.
>>>>> but i also remember that i used dnf to get tkInnter installed:
>>>>> rpm -qa | grep tkin
>>>>> python3-tkinter-3.5.3-6.fc24.x86_64
>>>>> tkinter-2.7.13-2.fc24.x86_64
>>>>> tix-1:8.4.3-17.fc24.x86_64
>>>>> if i were to compare "pip3 list" between system (root) and the user
>>>>> (az):
>>>>> diff -u /tmp/root_pip /tmp/usr_pip
>>>>> --- /tmp/root_pip    2017-11-04 15:26:09.612643559 -0400
>>>>> +++ /tmp/usr_pip    2017-11-04 15:25:52.396473226 -0400
>>>>> @@ -1,39 +1,65 @@
>>>>>  astroid (1.4.5)
>>>>>  beautifulsoup4 (4.6.0)
>>>>> +bleach (2.1)
>>>>>  blivet (1.20.3)
>>>>>  chardet (2.2.1)
>>>>>  coverage (4.4.1)
>>>>>  cssselect (0.9.1)
>>>>>  cupshelpers (1.0)
>>>>> +cx-Oracle (6.0.2)
>>>>>  cycler (0.10.0)
>>>>>  decorator (4.0.11)
>>>>>  distro (1.0.2)
>>>>>  dnf-langpacks (0.15.1)
>>>>> +entrypoints (0.2.3)
>>>>>  fros (1.1)
>>>>> -html5lib (0.999)
>>>>> +html5lib (1.0b10)
>>>>>  humanize (0.5.1)
>>>>>  ib-insync (0.8.5)
>>>>> +ibapi (9.73.2)
>>>>>  iniparse (0.4)
>>>>>  initial-setup (0.3.40)
>>>>>  IPy (0.81)
>>>>> +ipykernel (4.6.1)
>>>>> +ipython (6.2.0)
>>>>> +ipython-genutils (0.2.0)
>>>>>  ipywidgets (7.0.0)
>>>>>  isc (1.0)
>>>>>  javapackages (4.6.0)
>>>>> +jedi (0.11.0)
>>>>> +Jinja2 (2.9.6)
>>>>> +jsonschema (2.6.0)
>>>>>  jupyter (1.0.0)
>>>>> +jupyter-client (5.1.0)
>>>>> +jupyter-console (5.2.0)
>>>>> +jupyter-core (4.3.0)
>>>>>  langtable (0.0.35)
>>>>>  lazy-object-proxy (1.2.1)
>>>>>  lxml (3.7.2)
>>>>> +MarkupSafe (1.0)
>>>>> +matplotlib (2.1.0)
>>>>> +mistune (0.7.4)
>>>>> +nbconvert (5.3.1)
>>>>> +nbformat (4.4.0)
>>>>> +notebook (5.1.0)
>>>>>  ntplib (0.3.3)
>>>>>  numpy (1.13.3)
>>>>>  ordered-set (2.0.0)
>>>>>  pandas (0.20.3)
>>>>> +pandocfilters (1.4.2)
>>>>> +parso (0.1.0)
>>>>> +pexpect (4.2.1)
>>>>> +pickleshare (0.7.4)
>>>>>  pid (2.0.1)
>>>>>  Pillow (3.2.0)
>>>>>  pip (9.0.1)
>>>>> +prompt-toolkit (1.0.15)
>>>>> +ptyprocess (0.5.2)
>>>>>  pwquality (1.3.0)
>>>>>  pycups (1.9.72)
>>>>>  pycurl (7.43.0)
>>>>>  pyenchant (1.6.8)
>>>>> +Pygments (2.2.0)
>>>>>  pygobject (3.20.1)
>>>>>  pygpgme (0.3)
>>>>>  pyinotify (0.9.6)
>>>>> @@ -42,6 +68,7 @@
>>>>>  pylint (1.5.6)
>>>>>  pyparsing (2.2.0)
>>>>>  pyparted (3.10.7)
>>>>> +PyQt5 (5.9)
>>>>>  PySocks (1.5.6)
>>>>>  python-augeas (0.5.0)
>>>>>  python-dateutil (2.6.1)
>>>>> @@ -50,6 +77,9 @@
>>>>>  pytz (2017.2)
>>>>>  pyudev (0.21.0)
>>>>>  pyxdg (0.25)
>>>>> +pyzmq (16.0.2)
>>>>> +qtconsole (4.3.1)
>>>>> +Quamash (0.5.5)
>>>>>  requests (2.10.0)
>>>>>  requests-file (1.4)
>>>>>  requests-ftp (0.3.1)
>>>>> @@ -60,11 +90,21 @@
>>>>>  sepolicy (1.1)
>>>>>  setroubleshoot (1.1)
>>>>>  setuptools (20.1.1)
>>>>> +simplegeneric (0.8.1)
>>>>> +sip (4.19.3)
>>>>>  six (1.11.0)
>>>>>  slip (0.6.4)
>>>>>  slip.dbus (0.6.4)
>>>>>  sos (3.2)
>>>>>  SSSDConfig (1.15.3)
>>>>>  systemd-python (232)
>>>>> +terminado (0.6)
>>>>> +testpath (0.3.1)
>>>>> +tornado (4.5.2)
>>>>> +traitlets (4.3.2)
>>>>> +tws-async (0.5.5)
>>>>>  urllib3 (1.15.1)
>>>>> +wcwidth (0.1.7)
>>>>> +webencodings (0.5.1)
>>>>> +widgetsnbextension (3.0.3)
>>>>>  wrapt (1.10.10)
>>>>>
>>>>>
>>>>> I just removed html5lib from system(root) , but tha made no difference
>>>>> to the plotting..
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Sat, Nov 4, 2017 at 11:09 AM, Andrew Z <formisc at gmail.com> wrote:
>>>>>
>>>>>> hello,
>>>>>>  the issue i'm experiencing is local to my laptop ( the other
>>>>>> machines i have run examples just fine).
>>>>>> I described it here https://www.mail-archive.com/p
>>>>>> ython-list at python.org/msg432343.html in details.
>>>>>> i searched around, but none of the proposed workarounds helped.
>>>>>>
>>>>>> Is there a  way to enable some-kind of debugging or verbose output to
>>>>>> see what exactly is happening behind the scene?
>>>>>>
>>>>>> Thank you.
>>>>>> AZ
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Matplotlib-users mailing list
>>>>> Matplotlib-users at python.org
>>>>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>>>>
>>>>>
>>>>
>>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171108/02e51974/attachment-0001.html>


More information about the Matplotlib-users mailing list