Upgraded and installed macports on Mojave, resulting in "ImportError: cannot import name _tkagg"

Balthasar Indermuehle balt at inside.net
Mon May 6 07:24:01 UTC 2019


I have python code that depends on the TkAgg matplotlib backend. I have
upgraded and reinstalled all macports after upgrading to Mojave 10.14.4
following the migration instructions here
https://trac.macports.org/wiki/Migration and all seems to work fine, with
the exception of the tkagg backend it can't seem to locate.

Before I mess anything up by force uninstalling and reinstallng py-tkinter,
does anyone have suggestions on what else to try first?

Here's the exact error I get on trying to run this code:

[balt@:mymachine]$
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Python 2.7.16 (default, Apr  1 2019, 14:50:41)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.use("TkAgg",warn=False, force=True)
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py",
line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show =
pylab_setup()
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/__init__.py",
line 63, in pylab_setup
    [backend_name], 0)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py",
line 4, in <module>
    from . import tkagg  # Paint image to Tk photo blitter extension.
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py",
line 9, in <module>
    from matplotlib.backends import _tkagg
ImportError: cannot import name _tkagg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20190506/ced6143b/attachment.html>


More information about the macports-users mailing list