【问题标题】:Error during Spacy installation with pip使用 pip 安装 Spacy 时出错
【发布时间】:2015-05-23 15:13:24
【问题描述】:

我正在尝试在我的计算机上安装 Spacy,但是当我运行时

pip.exe install spacy

我收到此错误:

Requirement already satisfied (use --upgrade to upgrade): spacy in c:\python27
Collecting numpy (from spacy)
  Using cached numpy-1.9.2.tar.gz
    Running from numpy source directory.
Collecting murmurhash (from spacy)
  Using cached murmurhash-0.24.tar.gz
    warning: manifest_maker: MANIFEST.in, line 5: 'recursive-include' expects <dir> <pattern1> <pattern2> ...
    warning: manifest_maker: MANIFEST.in, line 6: unknown action '*.py'
    warning: manifest_maker: MANIFEST.in, line 7: unknown action '*.rst'
Collecting cymem>=1.11 (from spacy)
  Using cached cymem-1.11.tar.gz
Collecting preshed (from spacy)
  Using cached preshed-0.37.tar.gz
    zip_safe flag not set; analyzing archive contents...
    headers_workaround.__init__: module references __file__
Installed c:\users\hp-por~1\appdata\local\temp\pip-build-y5elnp\preshed\.eggs\headers_workaround-0.17-py2.7.egg
Collecting thinc (from spacy)
  Using cached thinc-1.75.tar.gz
    zip_safe flag not set; analyzing archive contents...
    headers_workaround.__init__: module references __file__
    Installed c:\users\hp-por~1\appdata\local\temp\pip-build-y5elnp\thinc\.eggs\headers_workaround-0.17-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): unidecode in c:\python27\lib\site-packages (from spacy)
Requirement already satisfied (use --upgrade to upgrade): wget in c:\python27\lib\site-packages (from spacy)
Requirement already satisfied (use --upgrade to upgrade): plac in c:\python27\lib\site-packages (from spacy)
Requirement already satisfied (use --upgrade to upgrade): six in c:\python27\lib\site-packages (from spacy)
Installing collected packages: thinc, preshed, cymem, murmurhash, numpy
  Running setup.py install for thinc
    building 'thinc.learner' extension
    C:\Users\HP-PORTABLE\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I. -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC /Tpthinc/learner.cpp /Fobuild\temp.win32-2.7\Release\thinc/learner.obj -O3
    cl : Command line warning D9002 : ignoring unknown option '-O3'
    learner.cpp
    thinc/learner.cpp(238) : fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory
    error: command 'C:\\Users\\HP-PORTABLE\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
    Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\hp-por~1\\appdata\\local\\temp\\pip-build-y5elnp\\thinc\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\hp-por~1\appdata\local\temp\pip-qxxztl-record\install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build\lib.win32-2.7

creating build\lib.win32-2.7\thinc

copying thinc\context_fields.py -> build\lib.win32-2.7\thinc

copying thinc\util.py -> build\lib.win32-2.7\thinc

copying thinc\__init__.py -> build\lib.win32-2.7\thinc

copying thinc\cache.pyx -> build\lib.win32-2.7\thinc

copying thinc\cy_svm.pyx -> build\lib.win32-2.7\thinc

copying thinc\features.pyx -> build\lib.win32-2.7\thinc

copying thinc\learner.pyx -> build\lib.win32-2.7\thinc

copying thinc\search.pyx -> build\lib.win32-2.7\thinc

copying thinc\thinc.pyx -> build\lib.win32-2.7\thinc

copying thinc\weights.pyx -> build\lib.win32-2.7\thinc

copying thinc\cache.pxd -> build\lib.win32-2.7\thinc

copying thinc\cy_svm.pxd -> build\lib.win32-2.7\thinc

copying thinc\features.pxd -> build\lib.win32-2.7\thinc

copying thinc\learner.pxd -> build\lib.win32-2.7\thinc

copying thinc\search.pxd -> build\lib.win32-2.7\thinc

copying thinc\thinc.pxd -> build\lib.win32-2.7\thinc

copying thinc\typedefs.pxd -> build\lib.win32-2.7\thinc

copying thinc\weights.pxd -> build\lib.win32-2.7\thinc

copying thinc\__init__.pxd -> build\lib.win32-2.7\thinc

copying thinc\compile_time_constants.pxi -> build\lib.win32-2.7\thinc

running build_ext

building 'thinc.learner' extension

creating build\temp.win32-2.7

creating build\temp.win32-2.7\Release

creating build\temp.win32-2.7\Release\thinc

C:\Users\HP-PORTABLE\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I. -IC:\Python27\include -IC:\Python27\include -IC:\Python27\PC /Tpthinc/learner.cpp /Fobuild\temp.win32-2.7\Release\thinc/learner.obj -O3

cl : Command line warning D9002 : ignoring unknown option '-O3'

learner.cpp

thinc/learner.cpp(238) : fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory

error: command 'C:\\Users\\HP-PORTABLE\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\hp-por~1\\appdata\\local\\temp\\pip-build-y5elnp\\thinc\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\hp-por~1\appdata\local\temp\pip-qxxztl-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\hp-por~1\appdata\local\temp\pip-build-y5elnp\thinc

我已经升级了 setuptools,但没有任何变化。 我正在运行 Windows 7 64b。 我已经为 python 2.7 安装了 Visual C++ 编译器包。 我正在尝试在 2 台不同的 PC 上安装,但出现相同的错误。

【问题讨论】:

标签: python


【解决方案1】:

在 Windows 中,我在通过 pip 安装软件包时遇到了很多问题。我发现的一个解决方案(我仍然使用它)它使用“virtualenv”来为我的项目创建虚拟环境。 Pip 似乎在 venvs 而不是 C: 路由中工作得更好。

您可以通过 pip pip install virtualenv 安装 virtualenv 或查看 installation guide.

安装后,只需在您的项目路径(或任何您想要的位置)中创建一个 virtualenv 并激活它。打开一个cmd终端并使用:

> virtualenv name_of_the_enviroment
> name_of_the_enviroment/Scripts/activate
> pip install spacy

我不建议将你的 python 路由放在你的环境变量中,这样你就可以在 cmd 终端中使用“pip”、“python”等。

现在,当您使用“pip install some_package”时,它将被安装在 virtualenv 中。 deactivate 将停用 virtualenv。

注意:请注意,当您想要使用包或使用已安装的包启动项目时,必须激活 virtualenv。

【讨论】:

  • 谢谢,但是当我在新环境(名称为 myspacy)中运行时出现相同的错误: (myspacy) C:\Python27\Scripts\myspacy\Scripts>pip.exe install spacy。
【解决方案2】:

它可能与安装在您的虚拟环境 (venv) 中的其他 python 包发生冲突。我就是这种情况。我尝试将 pip 安装到已经安装了这些软件包的 venv 中:

appnope==0.1.0
beautifulsoup4==4.5.1
bs4==0.0.1
chardet==2.3.0
cloudpickle==0.2.1
cssselect==1.0.0
cymem==1.31.2
decorator==4.0.10
entrypoints==0.2.2
headers-workaround==0.18
ipykernel==4.5.2
ipython==5.1.0
ipython-genutils==0.1.0
ipywidgets==5.2.2
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.4.0
jupyter-console==5.0.0
jupyter-core==4.2.1
lxml==3.6.4
MarkupSafe==0.23
mistune==0.7.3
murmurhash==0.26.4
nbconvert==4.2.0
nbformat==4.2.0
notebook==4.2.3
numpy==1.11.2
pandas==0.19.1
pathlib==1.0.1
pdfminer.six==20160614
pdfminer3k==1.3.1
pdfquery==0.4.3
pexpect==4.2.1
pickleshare==0.7.4
plac==0.9.6
ply==3.9
preshed==0.46.4
prompt-toolkit==1.0.9
ptyprocess==0.5.1
py==1.4.31
Pygments==2.1.3
pyquery==1.2.17
pytest==3.0.3
python-dateutil==2.6.0
pytz==2016.7
pyzmq==16.0.2
qtconsole==4.2.1
requests==2.11.1
roman==2.0.0
semver==2.7.2
simplegeneric==0.8.1
six==1.10.0
slate==0.3
sputnik==0.9.3
terminado==0.6
thinc==5.0.8
tornado==4.4.2
traitlets==4.3.1
ujson==1.35
wcwidth==0.1.7
widgetsnbextension==1.2.6

即使升级 setuptools,它也一直失败。

尝试创建一个全新的环境conda create -n spacy python=3,继续安装默认软件包(openssl、pip、wheel 等)并(在激活新的 venv source activate spacy 后)然后运行 ​​pip install -U spacy。它安装到虚拟环境中没有问题。从那里安装您需要的其他软件包。

【讨论】: