I use OS X Yosemite with a Homebrew-installed Python 3.5.
Trying to install NumPy with pip3 install numpy
results in the following error
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
How do I go about this?
这是一个已知的错误,应尽快修复: https : //github.com/Homebrew/homebrew/issues/43916
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
Try to install python development library.
I had the same problems.
The following helped me:
Download (with your browser) and install miniconda for python35 (64 bit in my case). See:
http://conda.pydata.org/miniconda.html
Make the downloaded script executable
chmod 777 <scriptname>
and run it with suitable privileges.
Install numpy with
conda install numpy
again with suitable privileges.
Instead of sudo'ing everything, sudo xterm and work from there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.