Scikit learn Scikit了解无法在OS X上安装:未声明的标识符和分配错误
在尝试在我的机器上安装scikit learn时,我遇到了问题。我使用自制的Python 2.7.5运行OS X 10.8.4,并且安装了最新版本的Scipy和Numpy 我尝试过通过Pip安装scikit learn,也尝试过克隆最新的源代码并从头开始构建—这就是我每次尝试构建scikit learn时得到的结果。知道这是怎么回事吗Scikit learn Scikit了解无法在OS X上安装:未声明的标识符和分配错误,scikit-learn,Scikit Learn,在尝试在我的机器上安装scikit learn时,我遇到了问题。我使用自制的Python 2.7.5运行OS X 10.8.4,并且安装了最新版本的Scipy和Numpy 我尝试过通过Pip安装scikit learn,也尝试过克隆最新的源代码并从头开始构建—这就是我每次尝试构建scikit learn时得到的结果。知道这是怎么回事吗 1 warning and 3 errors generated. In file included from sklearn/feature_extractio
1 warning and 3 errors generated.
In file included from sklearn/feature_extraction/_hashing.c:258:
In file included from /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15:
In file included from /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17:
In file included from /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1728:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
^
sklearn/feature_extraction/_hashing.c:2439:15: error: assigning to 'int' from incompatible type 'void'
__pyx_t_2 = PyErr_BadArgument(); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^ ~~~~~~~~~~~~~~~~~~~
sklearn/feature_extraction/_hashing.c:4833:96: error: use of undeclared identifier 'PyBoolObject'
__pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^
sklearn/feature_extraction/_hashing.c:4834:105: error: use of undeclared identifier 'PyComplexObject'
__pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^
1 warning and 3 errors generated.
error: Command "cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c sklearn/feature_extraction/_hashing.c -o build/temp.macosx-10.8-x86_64-2.7/sklearn/feature_extraction/_hashing.o" failed with exit status 1
升级到OSX 10.9 Mavericks后,我遇到了同样的构建问题。我通过运行以下命令解决了此问题:
xcode-select --install
更新XCode命令行工具
我还通过以下方式升级了所有自制库:
brew update
brew doctor
# fix all reported issues
brew upgrade
<>我必须卸载和重新安装以前建立的依赖于C++标准库的不兼容版本的依赖项。 < P>我在OSX 10.9小牛身上也有类似的问题,也许它会帮助您在OSX0.84上使用,或者在将来升级您的系统时。在进一步研究的基础上,我了解到您需要安装XCode命令行工具,通常在终端上运行:
xcode-select --install
如果有效,您可以直接进入本答案末尾的自制步骤。但是,一些用户(如我自己)可能在运行这个命令时遇到问题,因为命令行工具现在是随Xcode提供的,不再以这种方式提供。它可能会说:
“无法安装软件,因为软件更新服务器当前不提供该软件。”
事实证明,升级或重新安装Xcode也可能不起作用,很显然,它不是以这种方式为我提供的。幸运的是,还有另一种获取此命令行工具的方法(我读过):
Xcode.app
的是对我有用的。通过这种方式,您当然可以防止Git命令行中断带来的另一个问题,这将在下一步也是最后一步让您感到困扰:自制。这是因为自制依赖于Git才能正常工作
自制步骤:
brew update
brew doctor
# fix all reported issues
brew upgrade
如果仍然无法工作,请重新安装Homebrew(),然后重新安装。我希望这能解决您的问题:)NumPy和SciPy的版本到底是什么?NumPy的版本是1.7.1,SciPy的版本是0.12.0。这不是讨论bug的理想格式,但您是否安装了Cython?如果没有,请使用
pip install cython
?Installed cython,结果相同。我知道这并不理想,但我想在提交问题之前,我应该确保自己没有做傻事。我现在就去做,并从这里链接到它;我想建议您在sklearn/feature\u extraction/\u hashing.pyx
上运行Cython,然后重新编译并重试。我也在Mavericks上,但当我运行xcode select--install
时,它会说“无法安装软件,因为软件更新服务器当前不提供该软件。”。我在某个地方读到,这是因为命令行工具现在与Xcode一起提供,但我有最新版本5.0.1,但它仍然不能工作。重新安装后没有任何变化,你知道怎么做吗?对不起,不知道。但是如果你发现了这个问题,请把这个解决方案作为这个问题的新答案报告回来。
sudo xcode-select -switch /Library/Developer/CommandLineTools
brew update
brew doctor
# fix all reported issues
brew upgrade