构建spacy的轮子失败。

26
我试图通过运行 pip install spacy 来安装适用于 Python 版本 3.6.1 的 spacy,但是我不断收到以下错误,请问如何解决这个问题?之前我遇到了 cl.exe 未找到的错误,然后我将 visual studio 路径添加到环境变量中,cl.exe 就在其中。
     Failed building wheel for spacy
  Running setup.py clean for spacy
  Running setup.py bdist_wheel for murmurhash ... error
  Complete output from command c:\users\sh00428701\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SH0042~1\\AppData\\Local\\Temp\\pip-build-joi6voav\\murmurhash\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\SH0042~1\AppData\Local\Temp\tmpa6tzdkovpip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
----------------------------------------
  Failed building wheel for murmurhash
  Running setup.py clean for murmurhash
  Running setup.py bdist_wheel for cymem ... error
  Complete output from command c:\users\sh00428701\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SH0042~1\\AppData\\Local\\Temp\\pip-build-joi6voav\\cymem\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\SH0042~1\AppData\Local\Temp\tmpz7p6hkiwpip-wheel- --python-tag cp36:

 ----------------------------------------
  Failed building wheel for cymem
  Running setup.py clean for cymem
  Running setup.py bdist_wheel for preshed ... error
  Complete output from command c:\users\sh00428701\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SH0042~1\\AppData\\Local\\Temp\\pip-build-joi6voav\\preshed\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\SH0042~1\AppData\Local\Temp\tmpwppgmyp9pip-wheel- --python-tag cp36:

  ----------------------------------------
  Failed building wheel for preshed
  Running setup.py clean for preshed
  Running setup.py bdist_wheel for thinc ... error
 ----------------------------------------
  Failed building wheel for thinc
  Running setup.py clean for thinc
  Running setup.py bdist_wheel for ujson ... error
  ----------------------------------------
  Failed building wheel for ujson
  Running setup.py clean for ujson
  Running setup.py bdist_wheel for cytoolz ... error
  ----------------------------------------
  Failed building wheel for cytoolz
  Running setup.py clean for cytoolz
Failed to build spacy murmurhash cymem preshed thinc ujson cytoolz
Installing collected packages: murmurhash, cymem, preshed, wrapt, tqdm, toolz, cytoolz, plac, pyreadline, dill, termcolor, pathlib, thinc, ujson, regex, spacy
  Running setup.py install for murmurhash ... error

   C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\sh00428701\appdata\local\programs\python\python36\include -IC:\Users\SH0042~1\AppData\Local\Temp\pip-build-joi6voav\murmurhash\murmurhash\include -Ic:\users\sh00428701\appdata\local\programs\python\python36\include -Ic:\users\sh00428701\appdata\local\programs\python\python36\include /EHsc /Tpmurmurhash/mrmr.cpp /Fobuild\temp.win-amd64-3.6\Release\murmurhash/mrmr.obj /Ox /EHsc
    mrmr.cpp
    c1xx: fatal error C1083: Cannot open source file: 'murmurhash/mrmr.cpp': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\users\sh00428701\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SH0042~1\\AppData\\Local\\Temp\\pip-build-joi6voav\\murmurhash\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\SH0042~1\AppData\Local\Temp\pip-_j1cxej1-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\SH0042~1\AppData\Local\Temp\pip-build-joi6voav\murmurhash\
12个回答

32

对于我来说,pip install --no-cache-dir spacy 是可行的。


太棒了!我花了好几个小时才弄明白这个问题。这一行简单的代码让我保持了理智。谢谢! - greenbergé
1
如果安装失败是因为您的 /tmp 卷空间不足,那么正确的解决方案是增加该卷的可用空间。 - rfinz

18

2
第一个选项对我在Windows 64位,Python 2.7上有效。只是需要注意你还需要从以下网址获取cytoolz和ujson:https://www.lfd.uci.edu/~gohlke/pythonlibs/ - Mustard Tiger
1
兄弟,你刚刚在这个问题上救了我的命。非常感谢你。 - McMintz
1
什么是 Mac 的替代选择? - vivekanon
1
树莓派/ Linux 的替代品是什么? - Franva

17

我安装了这些包,然后它就可以工作了:

sudo apt-get install python-dev 
sudo apt-get install python3-dev 
sudo apt-get install libevent-dev

1
Windows 的等价物是什么? - Reddspark
RHEL中yum的等效物是什么? - Pramod S. Nikam
这是为Ubuntu准备的吗? - kRazzy R
在Windows上,您可以使用Cygwin的安装程序(如果您已经安装了Cygwin,则只需重新运行它)来添加这些软件包。 - VeraKozya

4
这对我有用:
# Note, use sudo. I'm in a docker image, so i dont need it.

# install dev libs
apt-get install python-dev -y && \
apt-get install python3-dev -y && \
apt-get install libevent-dev -y && \

# install new gcc
apt-get update && \
apt-get install build-essential software-properties-common -y && \
add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
apt-get update && \
apt-get install gcc-snapshot -y && \
apt-get update && \
apt-get install gcc-6 g++-6 -y && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
apt-get install gcc-4.8 g++-4.8 -y && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8;

请查看 https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91

根据反馈更新。 - Taivas Gogoljuk

2

conda install -c conda-forge spacy 对我来说有效。我使用的是Windows 10和Python 3.5.3 :: Anaconda custom (64-bit)

最初的回答:

conda install -c conda-forge spacy对我有用。我使用的是Windows 10和Python 3.5.3 :: Anaconda自定义版(64位)


1

从Github源代码中下载并安装。这是链接: https://github.com/explosion/spaCy

使用以下命令:

python -m pip install -U pip venv              # update pip & virtualenv
git clone https://github.com/explosion/spaCy   # clone spaCy
cd spaCy                                       # navigate into directory

venv .env                                      # create environment in .env
source .env/bin/activate                       # activate virtual environment
export PYTHONPATH=`pwd`                        # set Python path to spaCy directory
pip install -r requirements.txt                # install all requirements
python setup.py build_ext --inplace            # compile spaCy

如果不使用虚拟环境,可以只使用最后两个命令。请参照官方文档这里


1
如果您正在使用手动安装的Python 3.6,并尝试在3.6环境中安装,则可能缺少Python 3.6-dev。
sudo apt-get install python3.6-dev

也许还有

sudo apt-get install gcc

这是一个特定案例的答复。

根据问题,我认为原帖使用的是Windows系统。因此这可能对原帖没有帮助。 - Pretasoc
我同意。答案是为像我这样来搜索的人准备的。 - Abhishek Chauhan

1

yum -y groupinstall development

对我有用


1
如果您使用的是Ubuntu,只需执行以下操作:
sudo apt-get install build-essential python-dev git

现在通过以下方式安装spacy:

pip install -U spacy

1

Spacy需要64位Python。

卸载32位Python。安装64位Python。

再次尝试安装Spacy。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接