[英]“pip3 install numpy” fails on brewed Python 3.5
I use OS X Yosemite with a Homebrew-installed Python 3.5. 我使用OS X Yosemite和Homebrew安装的Python 3.5。
Trying to install NumPy with pip3 install numpy
results in the following error 尝试使用pip3 install numpy
安装NumPy会导致以下错误
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/setup.py", line 251, in <module>
setup_package()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/setup.py", line 243, in setup_package
setup(**metadata)
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/install.py", line 62, in run
r = self.setuptools_run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/install.py", line 36, in setuptools_run
return distutils_install.run(self)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/command/install.py", line 539, in run
self.run_command('build')
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build.py", line 39, in run
old_build.run(self)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 153, in run
self.build_sources()
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 170, in build_sources
self.build_extension_sources(ext)
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 329, in build_extension_sources
sources = self.generate_sources(sources, ext)
File "/private/var/folders/w_/6ddpl57d1hx5m1m_nbhwd3qw0000gn/T/pip-build-ocs2rs8s/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 432, in generate_config_h
moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
File "numpy/core/setup.py", line 42, in check_types
out = check_types(*a, **kw)
File "numpy/core/setup.py", line 293, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
notably failure to find Python.h
, which however does exist at /usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m/Python.h
特别是找不到Python.h
,但是在/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m/Python.h
确实存在
How do I go about this? 我该怎么做?
这是一个已知的错误,应尽快修复: https : //github.com/Homebrew/homebrew/issues/43916
SystemError: Cannot compile 'Python.h'. SystemError:无法编译'Python.h'。 Perhaps you need to install python-dev|python-devel. 也许你需要安装python-dev | python-devel。
Try to install python development library. 尝试安装python开发库。
I had the same problems. 我遇到了同样的问题。
The following helped me: 以下帮助我:
Download (with your browser) and install miniconda for python35 (64 bit in my case). 下载(使用您的浏览器)并安装miniconda for python35(在我的情况下为64位)。 See: 看到:
http://conda.pydata.org/miniconda.html
Make the downloaded script executable 使下载的脚本可执行
chmod 777 <scriptname>
and run it with suitable privileges. 并使用适当的权限运行它。
Install numpy with 安装numpy
conda install numpy
again with suitable privileges. 再次以适当的特权。
Instead of sudo'ing everything, sudo xterm and work from there. 而不是sudo'ing一切,sudo xterm和从那里工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.