(已解决)ModuleNotFoundError: No module named ‘pycocotools‘

win10系统 anaconda3 虚拟环境运行python3.8 的程序时出现这种错误。需要安装对应的包。

先安装cython

pip install Cython

如果安装速度慢,选择清华源安装

然后安装pycocotools

pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI

如果一切顺利,下面的内容不用看。

第二个命令的安装,可能因为网络慢 中断安装失败

如下图失败代码:

Collecting pycocotools
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\yang\appdata\local\temp\pip-install-x412aedn\pycocotools_b0fe926af74b45e0b5e19b1c2c98136e
  Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\YANG\AppData\Local\Temp\pip-install-x412aedn\pycocotools_b0fe926af74b45e0b5e19b1c2c98136e'
  fatal: unable to access 'https://github.com/philferriere/cocoapi.git/': OpenSSL SSL_read: Connection was reset, errno 10054
WARNING: Discarding git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI. Command errored out with exit status 128: git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\YANG\AppData\Local\Temp\pip-install-x412aedn\pycocotools_b0fe926af74b45e0b5e19b1c2c98136e' Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement pycocotools (unavailable) (from versions: 2.0.0, 2.0.1, 2.0.2a1, 2.0.2, 2.0.3, 2.0.4)
ERROR: No matching distribution found for pycocotools (unavailable)

解决方法:重新运行一下 上面的命令即可。耐心等待,速度比较慢。这个没有国内的源可以选择。

最后安装成功

安装成功的信息如下:

Collecting pycocotools
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\yang\appdata\local\temp\pip-install-njt3jl5w\pycocotools_82f7cd57cf2b4aa2a4b072bb27f175f4
  Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\YANG\AppData\Local\Temp\pip-install-njt3jl5w\pycocotools_82f7cd57cf2b4aa2a4b072bb27f175f4'
  Resolved https://github.com/philferriere/cocoapi.git to commit 2929bd2ef6b451054755dfd7ceb09278f935f7ad
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... done
  Created wheel for pycocotools: filename=pycocotools-2.0-cp38-cp38-win_amd64.whl size=78919 sha256=afd58812ead690ff95575de39883dd61a3d5927da5df27a2b60ff1817229ffea
  Stored in directory: C:\Users\YANG\AppData\Local\Temp\pip-ephem-wheel-cache-7thtvdkx\wheels\bd\1c\0d\8c82e1b9bc855b82e1eb53eadea4459efe171d2daf5a222701
Successfully built pycocotools
Installing collected packages: pycocotools
Successfully installed pycocotools-2.0

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值