Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Matplotlib.pyplot 2.0.0b2 fails to import with Conda Python 3.5 on OS X #6746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bryanwweber opened this issue Jul 15, 2016 · 7 comments
Closed

Comments

@bryanwweber
Copy link

I installed the Matplotlib 2.0.0 beta 2 from PyPi with pip on OS X 10.11.5 using Conda Python 3.5. It appeared to install from a wheel rather than building from source. Importing matplotlib.pyplot raises

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bryan/anaconda3/lib/python3.5/site-packages/matplotlib/pyplot.py", line 114, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Users/bryan/anaconda3/lib/python3.5/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/Users/bryan/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_macosx.py", line 19, in <module>
    from matplotlib.backends import _macosx
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. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ

There is no problem using a conda installed Matplotlib 1.5.1.

@jenshnielsen jenshnielsen added this to the 2.0 (style change major release) milestone Jul 15, 2016
@jenshnielsen
Copy link
Member

This is exactly as expected. And yes it is very much a problem on the regular Conda version too. Anaconda just chose to patch out that check in their version of the package with leads to it apparently working but the figures being partially broken in strange ways because python is not a framework build.

The solution is to either install python.app and use pythonw rather than python or use a different backend such as QT4Agg or QT5Agg which does not depend on a framework build. (Because it's not using Apples native gui widgets)

That being said we really need to update the documentation to reflect this before 2.0.

@bryanwweber
Copy link
Author

Ok thanks! Could this also be related to a further issue that I have related to the notebook with the default backend?

As discussed at SciPy 2016 Matplotlib BOF, I have an issue with plotting figures using the default Mac OS X backend in a Jupyter Notebook. I am using Matplotlib 1.5.1 installed using conda install in Python 3.5. A simple example is

%matplotlib
import matplotlib.pyplot as plt
plt.plot([0, 1], [0, 1])
plt.show()

The figure actually pops up behind the Chrome or Safari window, and there is no icon in the OS X dock to be able to select the figure. I'd be happy to attach a screengrab if it would be useful.

@jenshnielsen
Copy link
Member

That is exactly one of the issues that happens with the non framework build where you can't probably forground the figure.

@bryanwweber
Copy link
Author

OK thanks, I was advised to switch to the QT4Agg backend anyways, so I'll do that. This issue is solved to my satisfaction, please feel free to close it when you've complete whatever you plan to do with the docs!

@jenshnielsen
Copy link
Member

There is a solution here for doing it inside the notebook which is slightly more complicated. That example only applies to virutalenv thou

@jenshnielsen
Copy link
Member

This is related to #6418

For 2.0 I want at least

  • Document to use python.app and pythonw in conda. Both in error message and the docs
  • Document what to do with a Ipython kernel in the Jupyter notebook. Both for pip and conda installs
  • Should we change the error to a warning?

@efiring
Copy link
Member

efiring commented Nov 24, 2016

Closed by #7022.

@efiring efiring closed this as completed Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants