我在安装gensim模块时遇到问题。我成功安装了numpy和scipy依赖模块,但在安装gensim时遇到错误。 我尝试了Python pip install gives "Command "python setup.py egg_info" failed with error code 1"中给出的解决方案 但他们都没有工作。
这是错误:
>pip install --target="D:\python\packages" gensim
Collecting gensim
Using cached gensim-2.3.0-cp36-cp36m-win32.whl
Collecting scipy>=0.18.1 (from gensim)
Using cached scipy-0.19.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\abcde\AppData\Local\Temp\pip-build-hu8lzsjz\scipy\setup.py", line 416, in <module>
setup_package()
File "C:\Users\abcde\AppData\Local\Temp\pip-build-hu8lzsjz\scipy\setup.py", line 412, in setup_package
setup(**metadata)
File "c:\program files (x86)\python36-32\lib\distutils\core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\dist.py", line 315, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\dist.py", line 361, in fetch_build_eggs
replace_conflicting=True,
File "c:\program files (x86)\python36-32\lib\site-packages\pkg_resources\__init__.py", line 850, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "c:\program files (x86)\python36-32\lib\site-packages\pkg_resources\__init__.py", line 1122, in best_match
return self.obtain(req, installer)
File "c:\program files (x86)\python36-32\lib\site-packages\pkg_resources\__init__.py", line 1134, in obtain
return installer(requirement)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\dist.py", line 429, in fetch_build_egg
return cmd.easy_install(req)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\command\easy_install.py", line 653, in easy_install
not self.always_copy, self.local_index
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 636, in fetch_distribution
dist = find(requirement)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 617, in find
dist.download_location = self.download(dist.location, tmpdir)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 566, in download
found = self._download_url(scheme.group(1), spec, tmpdir)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 805, in _download_url
return self._attempt_download(url, filename)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 811, in _attempt_download
headers = self._download_to(url, filename)
File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 726, in _download_to
block = fp.read(bs)
File "c:\program files (x86)\python36-32\lib\http\client.py", line 449, in read
n = self.readinto(b)
File "c:\program files (x86)\python36-32\lib\http\client.py", line 493, in readinto
n = self.fp.readinto(b)
File "c:\program files (x86)\python36-32\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "c:\program files (x86)\python36-32\lib\ssl.py", line 1002, in recv_into
return self.read(nbytes, buffer)
File "c:\program files (x86)\python36-32\lib\ssl.py", line 865, in read
return self._sslobj.read(len, buffer)
File "c:\program files (x86)\python36-32\lib\ssl.py", line 625, in read
v = self._sslobj.read(len, buffer)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\abcde\AppData\Local\Temp\pip-build-hu8lzsjz\scipy\
答案 0 :(得分:0)
您提供的错误文本表明实际问题是(a)涉及尝试安装scipy
,gensim依赖该文本; (b)与断开的HTTPS连接有关,表明网络连接存在问题(或阻止安全连接的问题)。
此外,很少需要为--target
指定pip
;如果您的环境(可访问的可执行文件)设置正确,您就可以pip install gensim
。 (如果您要安装到非默认位置,当您的活动环境未使用您期望的库时,您可能会遇到问题。)
建议:
pip
正在使用的PyPI存储库的主页:https://pypi.python.org/pypi
pip install scipy
conda
分发工具,该工具往往针对Windows安装进行了优化。 (我通常更喜欢miniconda
变体,它只安装您请求的最少的一组内容。)此外,虽然Python,gensim和相关软件包可以在Windows系统上运行,但请注意,此类Python / NLP / ML开源上的大多数开发/测试都发生在Linux / OSX系统上。因此,在Windows上经常会出现额外的安装/配置问题,然后通常较少的事先记录的故障排除来自之前遇到过同样问题的人。因此,如果您有选择,这种工作在Linux / Unix系统上通常会变得非常顺畅。
答案 1 :(得分:0)
你可以通过两种方式安装genism: 1. pip install -U genism
2.install easy_install 那么
easy_install https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gz