No module named 'gensim'

在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导入看看:

此时就导入成功啦!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

*move on

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值