0

I'm trying to import a module under an alias, running into the following error. Can anyone help, please? Not sure how to troubleshoot the error. Thanks.

> import matplotlib.pyplot as plt
> 
> Traceback (most recent call last):   File "<input>", line 1, in
> <module>   File "/Applications/PyCharm
> CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py",
> line 21, in do_import
>     module = self._system_import(name, *args, **kwargs)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/pyplot.py",
> line 115, in <module>
>     _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backends/__init__.py",
> line 62, in pylab_setup
>     [backend_name], 0)   File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py",
> line 21, in do_import
>     module = self._system_import(name, *args, **kwargs)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py",
> line 17, in <module>
>     from matplotlib.backends import _macosx   File "/Applications/PyCharm
> CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py",
> line 21, in do_import
>     module = self._system_import(name, *args, **kwargs)

> RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not insta 
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
CodeGuyJr
  • 79
  • 1
  • 2
  • 9
  • (running Python 3.6.5) – CodeGuyJr Jul 30 '18 at 20:48
  • Please code-format error messages, rather than quote-formatting them. Quote-formatting destroys spacing and line break information. – user2357112 Jul 30 '18 at 20:49
  • 1
    I think the final error message is missing from the traceback. – ImportanceOfBeingErnest Jul 30 '18 at 20:53
  • @TrooperZ: This is not something you can fix by hitting the buttons to un-apply quote formatting and apply code formatting. Your edit just puts the broken spacing into code formatting without actually fixing it. – user2357112 Jul 30 '18 at 20:54
  • @ImportanceOfBeingErnest Sorry! I tried to edit the original but can't. Here's the last line: --->RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. [part 1...] – CodeGuyJr Jul 30 '18 at 21:04
  • [This](https://matplotlib.org/faq/osx_framework.html) could help. Or, using another backend. – ImportanceOfBeingErnest Jul 30 '18 at 21:06
  • If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information. [part 2] – CodeGuyJr Jul 30 '18 at 21:07
  • 1
    Oh, so this error message is actually pretty self-explanatory. It essentially already lists all the options you have. – ImportanceOfBeingErnest Jul 30 '18 at 21:10
  • **FOR PPL WHO ARE NEW (like me): there's a number of 'backends'--ways of interpreting the Python code (big hurray for jargon :P). I found the following bit of code in a collaborator's script and it fixed the issue (presumably by manually selecting a backend that plays nice): ... import matplotlib as plt ...plt.use('TkAgg') --thanks for the pointers @ImportanceOfBeingErnest – CodeGuyJr Aug 01 '18 at 19:55

0 Answers0