@cgohlke - have you seen this before by any chance?
@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?
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.
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.
wrong version of mpl_toolkits imported when installing mpl with python setup.py install --user #2590
https://github.com/matplotlib/matplotlib/issues/2611
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 fromhttps://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'.
@cgohlke - have you seen this before by any chance?
@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?
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.
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.
wrong version of mpl_toolkits imported when installing mpl with python setup.py install --user #2590
针对这个问题,木有特别好的解决方法。国内外目前实测可行的解决方法是:
1.先把python 2.7.x主程序完全卸载;
2.务必重启电脑(不重启是没有用的!)再安装;就这么简单;
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 runbut (I ran it in ipython)
I found that there is no
__init__.py
inmpl_toolkits
folder in installedsite-packages
which shows it a importable module. And after I manually added the__init__.py
copied fromhttps://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'.