簡體   English   中英

在Mac OS Lion上為Python3構建numpy / scipy

[英]Building numpy/scipy for Python3 on Mac OS Lion

我不能讓NumpyScipy在MAC OSX Lion上使用Python3。

我已成功使用pip來安裝numpy,scipy和matplotlib,它們與Python2.7配合得很好,但是在Python3中輸入import numpy會導致No module named numpy 我已經嘗試直接下載源代碼,然后運行'python3 setup.py build',但我得到了各種錯誤警告,一些紅色與fortran有關(例如'找不到可執行文件f95')。 最終失敗的錯誤消息是'RuntimeError:Broken toolchain:無法鏈接一個簡單的C程序',並且似乎與前一行'sh:gcc-4.2:command not found'有關。

Scipy網站建議c編譯器可能存在問題,但使用pip安裝python2.7時沒有出現同樣的問題。 我已按照網站上有關更改編譯器的說明進行操作,但這沒有任何區別。

我也試過從虛擬環境安裝:

mkvirtualenv -p python3.2 test1
pip install numpy

但這失敗了, Command python setup.py egg_info failed with error code 1 in /Users/Eddy/.virtualenvs/test1/build/numpy

我考慮過將python3設為默認值,然后我認為pip安裝可能會有效,但我不知道如何做到這一點。 有沒有人對我如何進行有任何建議? 謝謝。

我遇到了同樣的問題scipy / sparse / linalg / dsolve / superlumodule.c :268:9:錯誤:非空函數'PyInit _superlu'應該返回一個值[-Wreturn-type]

scipy郵件列表上有人建議如下:

what happens if you change the line 268 ( in scipy/sparse/linalg/dsolve/_superlumodule.c)

from 
return;

to 
return NULL;

果然它有效

我在這個問題上取得了一些進展,在Ned Deily的pythonmac郵件列表上得到了很多幫助。 我現在可以為python3構建numpy,但是scipy仍然無法構建。

要安裝numpy:scipy網站(http://www.scipy.org/Installing_SciPy/Mac_OS_X)建議使用三個類型命令解決C編譯器問題,但這些不夠用,還需要一個:

$ 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'

從源頭建設后應該工作。 詳情請見此處

構建scipy的問題:雖然我認為,我不知道這里的問題是什么,再次使用C編譯器。 以下是錯誤消息。 我非常感謝你對此事的任何想法。

謝謝,艾迪

錯誤消息:

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. 我在我的.bash_profile“export CC = gcc-4.2”中有這個,這可能是以前的OS X編譯問題的某種破解,我刪除了它。
  2. 通過我的XCode安裝從這里https://github.com/kennethreitz/osx-gcc-installer/安裝了獨立的GCC

啟動一個新的終端窗口和pip install numpy工作正常

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM