Gensim 未安装 - Windows 8.1 - Python

Gensim not installing - Windows 8.1 - Python

我正在尝试安装 Gensim,但我收到如下所示的错误。我正在 运行 在 Windows 8.1 机器上使用 Python 2.7.8 和 NumPy 1.9.0 安装 Anaconda 2.1.0。我已经有了 Windows SDK 8.1。

它说了一些关于已弃用的 NumPy 版本 1.7,这看起来很奇怪,因为我 运行正在使用 NumPy 1.9.0。

我还有一个带有 Python 3.4 的 Anaconda3 安装,尽管我从我的 PATH 中删除了它们以便能够在 cmd 中 运行 Python 2,因为我需要在 Python 2. 运行 python --version returns "Python 2.7.8".

中从事一个项目
In [9]: %run setup.py install
running install
running bdist_egg
running egg_info
writing requirements to gensim.egg-info\requires.txt
writing gensim.egg-info\PKG-INFO
writing top-level names to gensim.egg-info\top_level.txt
writing dependency_links to gensim.egg-info\dependency_links.txt
reading manifest file 'gensim.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.sh' under directory '.'
no previously-included directories found matching 'docs\src*'
writing manifest file 'gensim.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
building 'gensim.models.word2vec_inner' extension
C:\Program Files (x86)\Haskell Platform13.2.0.0\mingw\bin\gcc.exe -DMS_WIN64
-mdll -O -Wall -IC:\Users\Robert-Jan\Downloads\gensim-0.10.3\gensim-0.10.3\gensi
m\models -IC:\Anaconda\include -IC:\Anaconda\PC -IC:\Anaconda\lib\site-packages\
numpy\core\include -c ./gensim/models/word2vec_inner.c -o build\temp.win-amd64-2
.7\Release\.\gensim\models\word2vec_inner.o
In file included from C:\Anaconda\lib\site-packages\numpy\core\include/numpy/nda
rraytypes.h:1804:0,
                 from C:\Anaconda\lib\site-packages\numpy\core\include/numpy/nda
rrayobject.h:17,
                 from C:\Anaconda\lib\site-packages\numpy\core\include/numpy/arr
ayobject.h:4,
                 from ./gensim/models/word2vec_inner.c:232:
C:\Anaconda\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h:
12:9: note: #pragma message: C:\Anaconda\lib\site-packages\numpy\core\include/nu
mpy/npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disa
ble it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
./gensim/models/word2vec_inner.c: In function '__Pyx_RaiseArgtupleInvalid':
./gensim/models/word2vec_inner.c:9761:18: warning: unknown conversion type chara
cter 'z' in format
./gensim/models/word2vec_inner.c:9761:18: warning: format '%.1s' expects type 'c
har *', but argument 5 has type 'Py_ssize_t'
./gensim/models/word2vec_inner.c:9761:18: warning: unknown conversion type chara
cter 'z' in format
./gensim/models/word2vec_inner.c:9761:18: warning: too many arguments for format

./gensim/models/word2vec_inner.c: In function '__Pyx_RaiseTooManyValuesError':
./gensim/models/word2vec_inner.c:10235:18: warning: unknown conversion type char
acter 'z' in format
./gensim/models/word2vec_inner.c:10235:18: warning: too many arguments for forma
t
./gensim/models/word2vec_inner.c: In function '__Pyx_RaiseNeedMoreValuesError':
./gensim/models/word2vec_inner.c:10241:18: warning: unknown conversion type char
acter 'z' in format
./gensim/models/word2vec_inner.c:10241:18: warning: format '%.1s' expects type '
char *', but argument 3 has type 'Py_ssize_t'
./gensim/models/word2vec_inner.c:10241:18: warning: too many arguments for forma
t
./gensim/models/word2vec_inner.c: At top level:
C:\Anaconda\lib\site-packages\numpy\core\include/numpy/__multiarray_api.h:1629:1
: warning: '_import_array' defined but not used
C:\Anaconda\lib\site-packages\numpy\core\include/numpy/__ufunc_api.h:241:1: warn
ing: '_import_umath' defined but not used
./gensim/models/word2vec_inner.c: In function '__pyx_pf_5trunk_6gensim_6models_1
4word2vec_inner_train_sentence_sg':
./gensim/models/word2vec_inner.c:5271:59: warning: '__pyx_v_syn1' may be used un
initialized in this function
./gensim/models/word2vec_inner.c:5274:59: warning: '__pyx_v_syn1neg' may be used
 uninitialized in this function
./gensim/models/word2vec_inner.c:5275:28: warning: '__pyx_v_table' may be used u
ninitialized in this function
./gensim/models/word2vec_inner.c:5276:25: warning: '__pyx_v_table_len' may be us
ed uninitialized in this function
./gensim/models/word2vec_inner.c:5277:25: warning: '__pyx_v_next_random' may be
used uninitialized in this function
./gensim/models/word2vec_inner.c: In function '__pyx_pf_5trunk_6gensim_6models_1
4word2vec_inner_2train_sentence_cbow':
./gensim/models/word2vec_inner.c:6080:59: warning: '__pyx_v_syn1' may be used un
initialized in this function
./gensim/models/word2vec_inner.c:6083:59: warning: '__pyx_v_syn1neg' may be used
 uninitialized in this function
./gensim/models/word2vec_inner.c:6084:28: warning: '__pyx_v_table' may be used u
ninitialized in this function
./gensim/models/word2vec_inner.c:6085:25: warning: '__pyx_v_table_len' may be us
ed uninitialized in this function
./gensim/models/word2vec_inner.c:6086:25: warning: '__pyx_v_next_random' may be
used uninitialized in this function
writing build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.def
C:\Program Files (x86)\Haskell Platform13.2.0.0\mingw\bin\dllwrap.exe -DMS_WI
N64 -mdll -static --entry _DllMain@12 --output-lib build\temp.win-amd64-2.7\Rele
ase\.\gensim\models\libword2vec_inner.a --def build\temp.win-amd64-2.7\Release\.
\gensim\models\word2vec_inner.def -s build\temp.win-amd64-2.7\Release\.\gensim\m
odels\word2vec_inner.o -LC:\Anaconda\libs -LC:\Anaconda\PCbuild\amd64 -lpython27
 -lmsvcr90 -o build\lib.win-amd64-2.7\gensim\models\word2vec_inner.pyd
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x23fb): undefined reference to `_imp__PyExc_TypeError'
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x2406): undefined reference to `_imp__PyErr_Format'
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x2447): undefined reference to `_imp__PyDict_Next'
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x246f): undefined reference to `_imp__PyString_Type'
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x24aa): undefined reference to `_imp___PyString_Eq'
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x251f): undefined reference to `_imp___PyString_Eq'
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x2555): undefined reference to `_imp__PyUnicodeUCS2_Compare'
build\temp.win-amd64-2.7\Release\.\gensim\models\word2vec_inner.o:word2vec_inner
.c:(.text+0x2561): undefined reference to `_imp__PyErr_Occurred'
[...]

...它继续抛出未定义的引用。

原来问题是 Gensim 需要的 C 库是使用名为 gcc.dll 的程序编译的。 Anaconda 内置了这个程序,Haskell 平台也是如此。正如我之前一直在使用 Haskell,Python 安装程序使用的是 Haskell 版本的 gcc.dll,而不是 Anaconda 的 gcc.bat.

删除我的 Haskell 安装解决了问题。

我在 win64 中使用 python 3.4。我在安装gensim的时候遇到了同样的错误。然后在尝试了很多方法之后,我终于通过 "pip uninstall" numpy scipy 和 gensim 实现了,然后 "pip install" 来自以下站点的所有三个 .whl 文件:http://www.lfd.uci.edu/~gohlke/pythonlibs/

希望能帮到别人:)