看来matplotlib 1.3.1的64位版本安装文件有bug




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

 Open
fyears opened this  issue on 23 Nov 2013 · 4 comments

3 participants

Phil Elson Michael Droettboom
fyears commented  on 23 Nov 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 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'.

Phil Elson
Collaborator
pelson commented  on 3 Dec 2013

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

fyears commented  on 3 Dec 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?

Michael Droettboom
Owner
mdboom commented  on 4 Dec 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.

Michael Droettboom
Owner
mdboom commented  on 4 Dec 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.

Sign up for free  to join this conversation on GitHub. Already have an account?  Sign in to comment

https://github.com/matplotlib/matplotlib/issues/2611

3 participants

Phil Elson Michael Droettboom
fyears commented  on 23 Nov 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 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'.

Phil Elson
Collaborator
pelson commented  on 3 Dec 2013

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

fyears commented  on 3 Dec 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?

Michael Droettboom
Owner
mdboom commented  on 4 Dec 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.

Michael Droettboom
Owner
mdboom commented  on 4 Dec 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.

Sign up for free  to join this conversation on GitHub. Already have an account?  Sign in to comment

针对这个问题,木有特别好的解决方法。国内外目前实测可行的解决方法是:

1.先把python 2.7.x主程序完全卸载;

2.务必重启电脑(不重启是没有用的!)再安装;就这么简单;大笑





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值