10
任何機構可以幫我解決這個問題:我試圖在Python進口numpy的但未能成功:如何導入numpy的在Python Shell
>>> import numpy as np
x=np.array([[7,8,5],[3,5,7]],np.int32)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import numpy as np
File "C:\Python27\lib\numpy\__init__.py", line 127, in <module>
raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
如何改變我的工作目錄。我知道如何在matlab中做到這一點,但我是Python的新用戶,不知道如何去做。 – 2012-08-10 17:51:55
在您的終端中,請確保您在啓動python之前在其他目錄中。只要numpy文件夾位於系統的PYTHONPATH變量的某個位置,就可以從系統中的任何位置在python中導入numpy。如果你不確定所有這一切的意思,谷歌PYTHONPATH和導入python。 – DaveTheScientist 2012-08-10 17:55:46
我試過這個,但沒有工作; ,>>> os.getcwd() 'C:\\ Python27' >>> os.chdir('C:\ working directory') >>> import numpy – 2012-08-10 18:08:11