2012-01-13 134 views
5

這可能是一個簡單的問題,但我被卡住了:我想在Python 2.6中使用numpy。我附加在numpy的文件夾所在的路徑:用python 2.6導入numpy 2.6

C:\ Python26 \ LIB \站點包\

,也爲numpy的文件夾本身

C中的路徑:\ Python26 \ LIB \站點包\ numpy的

然而,出現此錯誤消息

x=np.array([[7,8,5][3,5,7]],np.int32) 


    Traceback (most recent call last): 
     File "<pyshell#12>", line 1, in <module> 
     x=np.array([[7,8,5][3,5,7]],np.int32) 
    NameError: name 'np' is not defined 

你能幫我嗎?

+5

你有沒有其實'作爲np'導入numpy? – 2012-01-13 14:39:06

回答

14

您不應該將這些東西添加到路徑中。只要在路徑中有C:\ Python26,Python就知道在哪裏查找已安裝的模塊。

斯文Marnach問,如果你這樣做是這樣的:

import numpy as np 
x=np.array([[7,8,5],[3,5,7]],np.int32) 

編輯:我剛纔注意到你離開了你的數組聲明還逗號......它固定在上面