Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip3 cannot find Python.h when installing numpy on OS X

My operating system is OSX 10.10.4 and I have both python2.7.10 and python3.5 and tried to install numpy, scipy and matplotlib for both this two versions of python.

In python2 it went well but as for python3, I tried to install numpy with command

pip3 install numpy

Then it turned out that the installation terminated because of it cannot find file Python.h But in fact the file python.h does exist in python3.5's directory. So I am quite confused now.

Update 18 Sept, the exact error messages: initially it tried to build numpy:

  compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -c'
  clang: _configtest.c
  _configtest.c:1:10: fatal error: 'Python.h' file not found
  #include <Python.h>
         ^
  1 error generated.
  _configtest.c:1:10: fatal error: 'Python.h' file not found
  #include <Python.h>
       ^
  1 error generated.
  failure.
  removing: _configtest.c _configtest.o
  Running from numpy source directory.
  /usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
  warnings.warn(msg)
  .....
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.

----------------------------------------
Failed building wheel for numpy
Failed to build numpy

and then the installation reported the same error.

like image 411
Bernard Yuan Avatar asked Nov 09 '22 05:11

Bernard Yuan


1 Answers

According to this page this is fixed in version 1.9.3 of numpy. Try

pip3 install numpy==1.9.3
like image 63
Barth Avatar answered Nov 14 '22 21:11

Barth