一、问题
最近安装glove, 搜了一下网上的资料,基本可以归纳为两步:第一:安装好gcc, 第二步:直接pip install glove_python;
可是等你执行pip install glove_python的时候,就报各种错误,比如:
C:\Users\pc\Desktop\glove_python-0.1.0>python setup.py install
running install
running bdist_egg
running egg_info
writing glove_python.egg-info\PKG-INFO
writing dependency_links to glove_python.egg-info\dependency_links.txt
writing requirements to glove_python.egg-info\requires.txt
writing top-level names to glove_python.egg-info\top_level.txt
reading manifest file 'glove_python.egg-info\SOURCES.txt'
writing manifest file 'glove_python.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
building 'glove.glove_cython' extension
D:\Dev-Cpp\MinGW64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -IC:\Users\pc\Anaconda3\include -IC:\Users\pc\Anaconda3\include -c glove/glove_cython.c -o build\temp.win-amd64-3.7\Release\glove\glove_cython.o -fopenmp -ffast-math -march=native
glove/glove_cython.c: In function '__Pyx_ExceptionSave':
glove/glove_cython.c:16753:19: error: 'PyThreadState' has no member named 'exc_type'
*type = tstate->exc_type;
^
glove/glove_cython.c:16754:20: error: 'PyThreadState' has no member named 'exc_value'
*value = tstate->exc_value;
^
glove/glove_cython.c:16755:17: error: 'PyThreadState' has no member named 'exc_traceback'
*tb = tstate->exc_traceback;
^
glove/glove_cython.c: In function '__Pyx_ExceptionReset':
glove/glove_cython.c:16767:22: error: 'PyThreadState' has no member named 'exc_type'
tmp_type = tstate->exc_type;
^
glove/glove_cython.c:16768:23: error: 'PyThreadState' has no member named 'exc_value'
tmp_value = tstate->exc_value;
^
glove/glove_cython.c:16769:20: error: 'PyThreadState' has no member named 'exc_traceback'
tmp_tb = tstate->exc_traceback;
^
glove/glove_cython.c:16770:11: error: 'PyThreadState' has no member named 'exc_type'
tstate->exc_type = type;
^
glove/glove_cython.c:16771:11: error: 'PyThreadState' has no member named 'exc_value'
tstate->exc_value = value;
^
glove/glove_cython.c:16772:11: error: 'PyThreadState' has no member named 'exc_traceback'
tstate->exc_traceback = tb;
^
glove/glove_cython.c: In function '__Pyx_GetException':
glove/glove_cython.c:16815:22: error: 'PyThreadState' has no member named 'exc_type'
tmp_type = tstate->exc_type;
^
glove/glove_cython.c:16816:23: error: 'PyThreadState' has no member named 'exc_value'
tmp_value = tstate->exc_value;
^
glove/glove_cython.c:16817:20: error: 'PyThreadState' has no member named 'exc_traceback'
tmp_tb = tstate->exc_traceback;
^
glove/glove_cython.c:16818:11: error: 'PyThreadState' has no member named 'exc_type'
tstate->exc_type = local_type;
^
glove/glove_cython.c:16819:11: error: 'PyThreadState' has no member named 'exc_value'
tstate->exc_value = local_value;
^
glove/glove_cython.c:16820:11: error: 'PyThreadState' has no member named 'exc_traceback'
tstate->exc_traceback = local_tb;
^
glove/glove_cython.c: In function '__Pyx_ExceptionSwap':
glove/glove_cython.c:16842:22: error: 'PyThreadState' has no member named 'exc_type'
tmp_type = tstate->exc_type;
^
glove/glove_cython.c:16843:23: error: 'PyThreadState' has no member named 'exc_value'
tmp_value = tstate->exc_value;
^
glove/glove_cython.c:16844:20: error: 'PyThreadState' has no member named 'exc_traceback'
tmp_tb = tstate->exc_traceback;
^
glove/glove_cython.c:16845:11: error: 'PyThreadState' has no member named 'exc_type'
tstate->exc_type = *type;
^
glove/glove_cython.c:16846:11: error: 'PyThreadState' has no member named 'exc_value'
tstate->exc_value = *value;
^
glove/glove_cython.c:16847:11: error: 'PyThreadState' has no member named 'exc_traceback'
tstate->exc_traceback = *tb;
^
error: command 'D:\Dev-Cpp\MinGW64\bin\gcc.exe' failed with exit status 1
或者就报这个错
running cythonize
Compiling glove/corpus_cython.pyx because it depends on C:\Users\pc\Anaconda3\lib\site-packages\Cython\Includes\libcpp\vector.pxd.
[1/1] Cythonizing glove/corpus_cython.pyx
C:\Users\pc\Anaconda3\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: G:\毕业设计\code\data\glove_python\glove-python-master\glove\corpus_cython.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
或者就是这个错
from glove import Glove
from glove import Corpus
ImportError: dlopen(/Users/thomas/anaconda/lib/python3.6/site-packages/glove/glove_cython.cpython-36m-darwin.so, 2): Symbol not found: _GOMP_parallel
Referenced from: /Users/thomas/anaconda/lib/python3.6/site-packages/glove/glove_cython.cpython-36m-darwin.so
Expected in: flat namespace
in /Users/thomas/anaconda/lib/python3.6/site-packages/glove/glove_cython.cpython-36m-darwin.so
方正就是一直安装不成功,具体原因我也不是特别清楚,这个glove包也是有点老了,中间也没有更新。
二、解决办法
1、直接输入如下命令
pip install glove-python-binary
2、下载源代码:https://github.com/maciejkula/glove-python/files/4622557/glove_python-0.1.0-cp37-cp37m-win_amd64.zip,解压放到site-packages中