使用brew为Python3安装numpy的OSX教程

4
我可以通过brew无法为python3安装numpy。
我输入了:
brew install numpy --with-python3

如果是Python2,则可以正常运行。

Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>

但是对于Python3仍然找不到

Python 3.4.0 (v3.4.0:04f714765c13, Mar 15 2014, 23:02:41) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>>

如何让它适用于Python3?
2个回答

5
正确的安装方式是通过以下步骤进行:
pip3 install numpy

显然,您需要先安装Python3和pip。我进行了测试,没有任何问题。


2
谢谢,我知道pip3很好用。也许我没有表达清楚,我需要从brew安装。这涉及到特定版本和其他依赖项。 - speedingdeer

0
Homebrew的问题在于它只能看到系统自带的Python以及它自己安装的那个Python。因此,在使用Homebrew之前,您需要先通过brew安装python3,并使用--with-python3选项来指定Python 3。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接