本文介绍了如何在Python Shell中导入NumPy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试用Python导入NumPy,但未成功:

I have tried importing NumPy in Python, but it did not succeed:

>>> 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 interpreter from there.

我该如何解决?

推荐答案

该消息相当不言自明;调用Python时,您的工作目录不应是NumPy源目录;应该安装NumPy,并且您的工作目录应该是该目录所在的目录.

The message is fairly self-explanatory; your working directory should not be the NumPy source directory when you invoke Python; NumPy should be installed and your working directory should be anything but the directory where it lives.

这篇关于如何在Python Shell中导入NumPy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:36
查看更多