在spyder中运行自然语言代码时,导入gensim模块显示
没有该模块
。
于是按照惯例,打开命令行(
快捷键可用“Win+R”
),使用
conda install +模块
,显示错误:
C:\Users\Administrator>
conda install gensim
Fetching package metadata …..
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
– gensim
– numpy-base
Use “conda info <package>” to see the dependencies for each package.
Emmm。按照惯例,我们使用第二招,
pip install +模块
,还是显示错误:
C:\Users\Administrator>
pip install gensim
Collecting gensim
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=’files.pythonhosted.org’, port=443): Read timed out. (read timeout=15)”,)’: /packages/f7/07/79584906b5a513842e5a7b9183ee5728c0bc0c3533e0686f7637f1ece6e8/gensim-3.8.2-cp36-cp36m-win_amd64.whl
Downloading gensim-3.8.2-cp36-cp36m-win_amd64.whl (24.2 MB)
|███ | 2.3 MB 15 kB/s eta 0:23:39ERROR: Exception:
Traceback (most recent call last):
File “e:\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 425, in _error_catcher
yield
File “e:\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 507, in read
data = self._fp.read(amt) if not fp_closed else b””
File “e:\anaconda3\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py”, line 62, in read
data = self.__fp.read(amt)
… … … … … …
File “e:\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 564, in stream
data = self.read(amt=amt, decode_content=decode_content)
File “e:\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 529, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File “e:\anaconda3\lib\contextlib.py”, line 99, in __exit__
self.gen.throw(type, value, traceback)
File “e:\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 430, in _error_catcher
raise ReadTimeoutError(self._pool, None, “Read timed out.”)
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=’files.pythonhosted.org’, port=443):
Read timed out
.
这里出错的关键提示是“
Read timed out
”。应该是网速的问题。没关系,记得收藏以下这两句,遇到类似问题,速度提升很多:
pip install -i https://pypi.douban.com/simple + 模块/包名
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple + 模块/包名
下面我们就用第一句来试一下:
C:\Users\Administrator>pip install -i https://pypi.douban.com/simple gensim
Looking in indexes: https://pypi.douban.com/simple
Collecting gensim
Downloading https://pypi.doubanio.com/packages/f7/07/79584906b5a513842e5a7b9183ee5728c0bc0c3533e0686f7637f1ece6e8/gensim-3.8.2-cp36-cp36m-win_amd64.whl (24.2 MB)
|████████████████████████████████| 24.2 MB 1.3 MB/s
Installing collected packages: gensim
Successfully installed
gensim-3.8.2
只要运行出现success就说明你的安装成功了!!!
第二句,有需要的可以试试。
提供第三句,试过也是可行的。
pip install -i https://pypi.douban.com/simple -U gensim
我们再次回去spyder导入看看:
此时就导入成功啦!