Quantcast

Building numpy/scipy for python3 on MacOS Lion

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Building numpy/scipy for python3 on MacOS Lion

Eddy Barratt
I can't get Numpy or Scipy to work with Python3 on Mac OSX Lion. 


I have used pip successfully to install numpy, scipy and matplotlib, and they work well with Python2.7, but in Python3 typing 'import numpy' brings up 'No module named numpy'. I've tried downloading the source code directly and then running 'python3 setup.py build', but I get various error warnings, some in red that have to do with fortran (e.g. 'Could not locate executable f95'). In the end I get the following message:

2 warnings generated.
gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.6-intel-3.2/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.6-intel-3.2 -o build/lib.macosx-10.6-intel-3.2/numpy/core/_dummy.so
sh: gcc-4.2: command not found
sh: gcc-4.2: command not found
error: Command "gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.6-intel-3.2/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.6-intel-3.2 -o build/lib.macosx-10.6-intel-3.2/numpy/core/_dummy.so" failed with exit status 127


The Scipy website (http://www.scipy.org/Installing_SciPy/Mac_OS_X) suggests that there may be issues with the c compiler, but the same problems didn't arise using pip to install for python2.7. I have followed the instructions on the website regarding changing the compiler but this has not made any difference. 


I have also tried installing using pip from a virtual environment: 

>>> source /usr/local/share/python/virtualenvwrapper.sh
>>> 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've considered making python3 default, and then I thought a pip install might work, but I don't know how to do that. Does anyone have any suggestions for how I might proceed? I'm all but ready to give up on Python3! 

Eddy 
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Building numpy/scipy for python3 on MacOS Lion

Ned Deily
In article <[hidden email]>,
 Eddy Barratt <[hidden email]> wrote:

> I can't get Numpy or Scipy to work with Python3 on Mac OSX Lion. 
>
>
> I have used pip successfully to install numpy, scipy and matplotlib, and they
> work well with Python2.7, but in Python3 typing 'import numpy' brings up 'No
> module named numpy'. I've tried downloading the source code directly and then
> running 'python3 setup.py build', but I get various error warnings, some in
> red that have to do with fortran (e.g. 'Could not locate executable f95'). In
> the end I get the following message:
>
> 2 warnings generated.
> gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot
> /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g
> build/temp.macosx-10.6-intel-3.2/numpy/core/src/dummymodule.o
> -Lbuild/temp.macosx-10.6-intel-3.2 -o
> build/lib.macosx-10.6-intel-3.2/numpy/core/_dummy.so
> sh: gcc-4.2: command not found
> sh: gcc-4.2: command not found
> error: Command "gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch
> x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot
> /Developer/SDKs/MacOSX10.6.sdk -g
> build/temp.macosx-10.6-intel-3.2/numpy/core/src/dummymodule.o
> -Lbuild/temp.macosx-10.6-intel-3.2 -o
> build/lib.macosx-10.6-intel-3.2/numpy/core/_dummy.so" failed with exit status
> 127
>
>
> The Scipy website (http://www.scipy.org/Installing_SciPy/Mac_OS_X) suggests
> that there may be issues with the c compiler, but the same problems didn't
> arise using pip to install for python2.7. I have followed the instructions on
> the website regarding changing the compiler but this has not made any
> difference. 

Chances are you are using a Python 3.2.x installer from python.org.  
Those Pythons are built using gcc-4.2 from Xcode 3 on OS X 10.6.  When
installing 3rd-party packages with C extension modules, Python's
Distutils will attempt to use the same compiler and compiler options  
Unfortunately, in the latest versions of Xcode 4, Apple has removed
gcc-4.2.  That's why you see the gcc-4.2 not found.  The instructions
given at the SciPy website for working around the problem by using clang
appear to be missing at least one important step.   Besides overriding
the CC environment variable, you also will need to override LDSHARED
(untested with SciPy!):

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

In the upcoming 3.2.3 maintenance release, Distutils will do the
equivalent automatically if gcc-4.2 is called for but not present on the
machine.

Chances are that you are using the Apple-supplied Python 2.7 in 10.7,
rather than a python.org version which should exhibit the same behavior
as what you see with Python 3.  The Apple system Python 2.7 is built
with llvm-gcc, not gcc-4.2, so you wouldn't see this problem with it.  
However, as the SciPy page notes, there have been test failures noted
when using llvm-gcc to build Python and it is recommend to not use it as
it is not being actively maintained and is intended as a stepping stone
to use of clang throughout OS X.

Note that, starting with Xcode 4.3, Apple has made yet another major
change: moving the contents of the former /Developer directory to inside
the Xcode.app bundle itself.  If you start with Xcode 4.3 or follow the
installation step of allowing Xcode to remove the old /Developer
directory, Distutils-initiated compiles will fail because they can't
find the SDK with OS X header files.  The workaround for that is to
create a symlink from the new location to the old:

$ sudo ln -s
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Deve
loper /Developer

--
 Ned Deily,
 [hidden email]

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Building numpy/scipy for python3 on MacOS Lion

Ned Deily
[Please keep the discussion on the list.  Thanks!]

On Mar 23, 2012, at 11:46 , Eddy Barratt wrote:

> Thanks Ned, that's great, now I can get numpy to import so I'm definitely getting somewhere. But scipy still won't build, it 'failed with exit status 1'. The error message included the command about LDSHARE in it's final paragraph. I've included the error message at the end of this email, starting from the part where it appears to have run in to issues.
>
> I have Xcode 4.2.1.
>
> Thanks for your help. Eddy
>
> Error Message:
>
> compiling C sources
> C compiler: clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -Os -w -pipe -march=core2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
>
> compile options: '-I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c'
> clang: scipy/cluster/src/vq_module.c
> clang: scipy/cluster/src/vq.c
> clang -bundle -undefined dynamic_lookup  -arch i386 x86_64 -isysroot/Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq_module.o build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq.o -Lbuild/temp.macosx-10.5-intel-2.7 -o build/lib.macosx-10.5-intel-2.7/scipy/cluster/_vq.so
> clang: error: no such file or directory: 'x86_64'
> clang: error: no such file or directory: 'x86_64'
> error: Command "clang -bundle -undefined dynamic_lookup  -arch i386 x86_64 -isysroot/Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq_module.o build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq.o -Lbuild/temp.macosx-10.5-intel-2.7 -o build/lib.macosx-10.5-intel-2.7/scipy/cluster/_vq.so" failed with exit status 1


It looks like a copy and paste error.  Note the environment variable settings I suggested were:

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

But in the Distutils output I see:  "-arch i386 x86_64"

--
  Ned Deily
  [hidden email] -- []


_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Building numpy/scipy for python3 on MacOS Lion

Eddy Barratt
Yeah, thanks, your right I typed it in wrong, but it still isn't working, though it did build for longer this time before failing.

This is the error code this time. It talks about something being depreciated in numpy. Thank you so much for your help with this.

Eddy

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




----- Original Message -----
From: Ned Deily <[hidden email]>
To: [hidden email]
Cc:
Sent: Friday, 23 March 2012, 14:23
Subject: Re: [Pythonmac-SIG] Building numpy/scipy for python3 on MacOS Lion

[Please keep the discussion on the list.  Thanks!]

On Mar 23, 2012, at 11:46 , Eddy Barratt wrote:

> Thanks Ned, that's great, now I can get numpy to import so I'm definitely getting somewhere. But scipy still won't build, it 'failed with exit status 1'. The error message included the command about LDSHARE in it's final paragraph. I've included the error message at the end of this email, starting from the part where it appears to have run in to issues.
>
> I have Xcode 4.2.1.
>
> Thanks for your help. Eddy
>
> Error Message:
>
> compiling C sources
> C compiler: clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -Os -w -pipe -march=core2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
>
> compile options: '-I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c'
> clang: scipy/cluster/src/vq_module.c
> clang: scipy/cluster/src/vq.c
> clang -bundle -undefined dynamic_lookup  -arch i386 x86_64 -isysroot/Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq_module.o build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq.o -Lbuild/temp.macosx-10.5-intel-2.7 -o build/lib.macosx-10.5-intel-2.7/scipy/cluster/_vq.so
> clang: error: no such file or directory: 'x86_64'
> clang: error: no such file or directory: 'x86_64'
> error: Command "clang -bundle -undefined dynamic_lookup  -arch i386 x86_64 -isysroot/Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq_module.o build/temp.macosx-10.5-intel-2.7/scipy/cluster/src/vq.o -Lbuild/temp.macosx-10.5-intel-2.7 -o build/lib.macosx-10.5-intel-2.7/scipy/cluster/_vq.so" failed with exit status 1


It looks like a copy and paste error.  Note the environment variable settings I suggested were:

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

But in the Distutils output I see:  "-arch i386 x86_64"

--
  Ned Deily
  [hidden email] -- []


_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Building numpy/scipy for python3 on MacOS Lion

Ned Deily
In article <[hidden email]>,
 Eddy Barratt <[hidden email]> wrote:

> Yeah, thanks, your right I typed it in wrong, but it still isn't working,
> though it did build for longer this time before failing.
>
> This is the error code this time. It talks about something
> being depreciated in numpy. Thank you so much for your help with this.
>
> Eddy
>
> 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-package
> s/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-package
> s/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

The deprecation warning isn't necessarily a problem but the compile
error is.  Sorry, I have no experience with scipy so I would only be
guessing what the problem here is.  Suggest you ask on the Scipy-User
mailing list (http://www.scipy.org/Mailing_Lists).  Good luck!

--
 Ned Deily,
 [hidden email]

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Loading...