Creating numpy / scipy for Python3 on Mac OS Lion

I cannot get Numpy or Scipy to work with Python3 on MAC OSX Lion.

I have successfully used pip to install numpy, scipy and matplotlib, and they work well with Python2.7, but in Python3, import numpy input calls No module named numpy . I tried to download the source code directly and then run "python3 setup.py build", but I get various error warnings, some in red, that are related to fortran (for example, "Could not find the executable file f95"). At the end of the error message, which seems to fail, is “RuntimeError: Broken toolchain: unable to link a simple C program” and seems to be related to the previous line “sh: gcc-4.2: command not found”.

The Scipy website suggests that there may be problems with the c compiler, but the same problems did not occur when using pip to install for python2 +0.7. I followed the instructions on the website regarding changing the compiler, but that didn't make any difference.

I also tried installing from a virtual environment:

 mkvirtualenv -p python3.2 test1 pip install numpy 

But this fails with Command python setup.py egg_info failed with error code 1 in /Users/Eddy/.virtualenvs/test1/build/numpy

I was considering creating python3 by default, and then I thought installing the package might work, but I don't know how to do it. Does anyone have any suggestions on how I can proceed? Thanks.

+4
source share
3 answers

I came across the same question scipy / sparse / linalg / dsolve / superlumodule.c: 268: 9: error: non-void function "PyInit_superlu" should return the value [-Wreturn-type]

Someone from the scipy mailing list suggested the following:

 what happens if you change the line 268 ( in scipy/sparse/linalg/dsolve/_superlumodule.c) from return; to return NULL; 

sure it worked

+4
source

I made some progress on this issue, with a lot of help from Ned Deily on the pythonmac mailing list. Now I can create numpy for python3, but scipy will still not be created.

To install numpy: The lean website (http://www.scipy.org/Installing_SciPy/Mac_OS_X) suggests working with the C compiler problem with three typed commands, but they are not enough, you need one more thing:

 $ export CC=clang $ export CXX=clang $ export FFLAGS=-ff2c $ export LDSHARED='clang -bundle -undefined dynamic_lookup \ -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -g' 

After this building from the source should work. See here for more details.

Creating scipy problems: I don’t know what the problem is here, something with the C compiler again, although I think. Here are the error messages. I would really appreciate any thoughts on this.

Thanks Eddie

error messages:

 compiling C sources C compiler: clang -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk compile options: '-DNO_ATLAS_INFO=3 -DUSE_VENDOR_BLAS=1 -I/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c' extra options: '-msse3' clang: scipy/sparse/linalg/dsolve/_superlumodule.c In file included from scipy/sparse/linalg/dsolve/_superlumodule.c:18: In file included from /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/arrayobject.h:15: In file included from /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/ndarrayobject.h:17: In file included from /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/ndarraytypes.h:1972: /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API" [-W#warnings] #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API" ^ scipy/sparse/linalg/dsolve/_superlumodule.c:268:9: error: non-void function 'PyInit__superlu' should return a value [-Wreturn-type] return; ^ 1 warning and 1 error generated. In file included from scipy/sparse/linalg/dsolve/_superlumodule.c:18: In file included from /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/arrayobject.h:15: In file included from /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/ndarrayobject.h:17: In file included from /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/ndarraytypes.h:1972: /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API" [-W#warnings] #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API" ^ scipy/sparse/linalg/dsolve/_superlumodule.c:268:9: error: non-void function 'PyInit__superlu' should return a value [-Wreturn-type] return; ^ 1 warning and 1 error generated. error: Command "clang -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -DNO_ATLAS_INFO=3 -DUSE_VENDOR_BLAS=1 -I/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c scipy/sparse/linalg/dsolve/_superlumodule.c -o build/temp.macosx-10.6-intel-3.2/scipy/sparse/linalg/dsolve/_superlumodule.o -msse3" failed with exit status 1 
+1
source

I had this problem and one of them sorted it out - not sure which one, but I turn it on for completeness:

  • I had this in my .bash_profile "export CC = gcc-4.2", which was probably a kind of hack from previous OS X compilation problems, I deleted it.
  • Installed standalone GCC from here https://github.com/kennethreitz/osx-gcc-installer/ through my Xcode installation

a new terminal window loaded and pip install numpy worked fine

0
source

Source: https://habr.com/ru/post/1400427/


All Articles