使用pip进行Spacy安装时出错

时间:2015-03-20 08:53:34

标签: python

我试图在我的计算机上安装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上安装相同的错误。

2 个答案:

答案 0 :(得分:0)

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

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

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

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

我几乎不建议将你的python路线放在你的环境变量中,所以你可以使用&#34; pip&#34;,&#34; python&#34;在cmd终端等。

现在,当你使用&#34; pip install some_package&#34;时,它将被安装在virtualenv中。 deactivate将停用virtualenv。

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

答案 1 :(得分:0)

它可能与您的虚拟环境(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之后)然后运行{{1 }}。它安装到虚拟环境中没有任何问题。从那里安装你需要的其他包。