1
我剛剛在我的windows 7 Python 2.6.5機器上安裝了matplotlib和win32安裝程序。我已經嘗試了matplotlib站點的一些示例來測試安裝, 在空閒everthing下正常工作,但Pydev 1.9(Eclipse 3.6)無法找到任何子模塊。Pydev找不到matplotlib模塊
e.g import matplotlib
不會引起任何錯誤
但from matplotlib.path import Path
拋出
ImportError: No module named path
伊夫在Eclipse中添加matplotlib路徑系統PYTHONPATH,還有什麼我需要做什麼?
from pylab import *
import numpy as np
from matplotlib.transforms import Bbox
from matplotlib.path import Path
from matplotlib.patches import Rectangle
rect = Rectangle((-1, -1), 2, 2, facecolor="#aaaaaa")
gca().add_patch(rect)
bbox = Bbox.from_bounds(-1, -1, 2, 2)
for i in range(12):
vertices = (np.random.random((4, 2)) - 0.5) * 6.0
vertices = np.ma.masked_array(vertices, [[False, False], [True, True], [False, False], [False, False]])
path = Path(vertices)
if path.intersects_bbox(bbox):
color = 'r'
else:
color = 'b'
plot(vertices[:,0], vertices[:,1], color=color)
show()
Traceback (most recent call last):
File "I:\My Documents\Programming\Python\Eclipse Projects\test\src\matplotlib.py", line 1, in <module>
from pylab import *
File "C:\Python26\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "I:\My Documents\Programming\Python\Eclipse Projects\test\src\matplotlib.py", line 3, in <module>
from matplotlib.transforms import Bbox
ImportError: No module named transforms
OMG多麼愚蠢......我把它叫做matplotlib_test.py謝謝! – volting 2010-08-19 21:35:56