过去两天我一直试图在我的Mac OSX上安装numpy。我也安装了Homebrew,然后运行命令 -
pip install numpy
给了我以下输出 -
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
然后我运行了命令 -
import numpy as np
给了我
-bash: import: command not found
非常感谢任何帮助。谢谢!
答案 0 :(得分:2)
如果从命令行运行import numpy
,则会出现错误:
$ import numpy as np
-bash: import: command not found
您需要启动Python,然后在Python解释器中键入import语句:
$ python
Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec 7 2015, 11:24:55)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.arange(5)
array([0, 1, 2, 3, 4])