Skip to content
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

no __init__.py in matplotlib-1.3.1.win-amd64-py2.7.exe #2611

Closed
fyears opened this issue Nov 22, 2013 · 6 comments
Closed

no __init__.py in matplotlib-1.3.1.win-amd64-py2.7.exe #2611

fyears opened this issue Nov 22, 2013 · 6 comments

Comments

@fyears
Copy link

fyears commented Nov 22, 2013

I downloaded matplotlib-1.3.1.win-amd64-py2.7.exe from http://matplotlib.org/downloads.html and tried to install matplotlib. After that, I tried to run

from mpl_toolkits.mplot3d import Axes3D

but (I ran it in ipython)

In [1]: from mpl_toolkits.mplot3d import Axes3D
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-a23df00dd457> in <module>()
----> 1 from mpl_toolkits.mplot3d import Axes3D

ImportError: No module named mpl_toolkits.mplot3d

I found that there is no __init__.py in mpl_toolkits folder in installed site-packages which shows it a importable module. And after I manually added the __init__.py copied from https://github.com/matplotlib/matplotlib/blob/master/lib/mpl_toolkits/__init__.py everything got okay.

I don't know whether it's caused by my machine or not. If it's indeed a bug, hope developers can fix this, since I spent lots of time 'fixing' this 'bug'.

@pelson
Copy link
Member

pelson commented Dec 3, 2013

@cgohlke - have you seen this before by any chance?

@fyears
Copy link
Author

fyears commented Dec 3, 2013

@pelson
Please extract matplotlib-1.3.1.win-amd64-py2.7.exe directly using 7zip (in windows) (or in Linux or OS X of course).

you can see

matplotlib-1.3.1.win-amd64-py2.7.exe\PLATLIB\matplotlib\
matplotlib-1.3.1.win-amd64-py2.7.exe\PLATLIB\mpl_toolkits\
...

There is a __init__.py in PLATLIB\matplotlib\ similar to (but NOT equivalent with) https://github.com/matplotlib/matplotlib/blob/v1.3.x/lib/matplotlib/__init__.py

but there isn't any __init__.py in PLATLIB\mpl_toolkits\.

Is this situation normal?

@mdboom
Copy link
Member

mdboom commented Dec 3, 2013

mpl_toolkits is declared as a namespace package, since other packages, such as basemap etc. put their own code in that namespace. But we do have an __init__.py in mpl_toolkits, and it does get installed as part of the normal python setup.py install process. Interestingly, it doesn't get included by python setup.py bdist, which is probably the basis of @cgohlke's Windows installers. Not sure yet whether that's normal or how that's supposed to work. We are in a slightly unusual situation here perhaps, because we have a namespace package but we also ship things with matplotlib that go in that namespace package. Let me do some more research and get back.

@mdboom
Copy link
Member

mdboom commented Dec 3, 2013

It looks like how this is supposed to work, is that there is a matplotlib-1.3.1-py2.7-nspkg.pth file in the installer that declares the namespace, and I suspect that is somehow failing.

The __init__.py is not installed, because then setuptools/installers would complain when a third-party toolkits, e.g. basemap, comes along and overrides it.

@tacaswell
Copy link
Member

Closing due to inactivity + affects old version of installer. Can you try with one of the rc installers? https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.4.0rc2/

@flalix
Copy link

flalix commented May 19, 2015

I don't know how PyInstaller work, and I almost get crazy.
My solution was:

a) the order of imports: first FileDialog (and I don't need it!!) ... after matplotlib ...

import FileDialog
import my_classes....
from Tkinter import END
import numpy as np
import matplotlib.pyplot as plt

b) in my_project.spec

hiddenimports = ['scipy.special._ufuncs_cxx','mpl_toolkits.mplot3d'],

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

5 participants