spacy的构建轮失败

时间:2017-04-12 13:24:10

标签: python scipy pip python-wheel spacy

我正在尝试通过运行pip install spacy for python version 3.6.1 来安装spacy但是我不断遇到如下错误,如何摆脱这个问题?以前我没有找到cl.exe错误,之后我在cl.exe存在的环境变量中添加了visual studio路径。

     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 个答案:

答案 0 :(得分:21)

对我来说,pip install --no-cache-dir spacy工作

答案 1 :(得分:17)

一些想法:

答案 2 :(得分:12)

我安装了这些软件包,然后就可以了:

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

答案 3 :(得分:2)

这对我有用:

# 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

答案 4 :(得分:1)

如果您使用的是Ubuntu,请执行此操作

sudo apt-get install build-essential python-dev git

现在按

安装spacy
pip install -U spacy

答案 5 :(得分:1)

从Gihub来源下载并安装。这是链接: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

如果不使用虚拟环境,可以随意仅使用最后两个命令。请遵循官方文档here

答案 6 :(得分:1)

如果将其与手动安装的python3.6一起使用并尝试在3.6环境中安装,则可能会缺少python3.6-dev

sudo apt-get install python3.6-dev

也许

sudo apt-get install gcc

这是对特定情况的答案。

答案 7 :(得分:1)

conda install -c conda-forge spacy为我工作。我有Windows 10和Python 3.5.3 :: Anaconda custom (64-bit)

答案 8 :(得分:0)

yum -y groupinstall开发

为我工作

答案 9 :(得分:0)

Spacy需要64位python。

卸载32位。 安装64位python。

再次尝试spacy安装。

答案 10 :(得分:0)

对于在 spacy 2.X 中使用 Python 3.8 寻找 Ubuntu 答案的人,我遇到了同样的问题。我正在使用 venv。由于其他答案还不够,我写了解决我问题的解决方案。

  1. 安装其他答案中提到的所需库:
sudo apt-get install python3-dev libevent-dev build-essential gcc g++
pip install setuptools wheel
  1. 更新 pip 并安装 cython
pip install -U pip
pip install cython

我怀疑将 pip 更新到最新版本解决了我的问题。

答案 11 :(得分:0)

首先,安装这些包并尝试安装 spacy

sudo apt update
sudo apt install python3-dev
sudo apt install libpython3-dev
sudo apt install python3-devel
sudo apt-get install libevent-dev
sudo apt update