Cannot uninstall ‘psutil‘. It is a distutils installed project and thus we cannot accurately determi

## 背景

安装mmcv时,提示

Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Collecting mmcv==2.1.0
  Using cached https://mirrors.aliyun.com/pypi/packages/a7/19/f97f0fd4d432113a232e75f965335be6b7bb6557ae9faf8051e9a012cadd/mmcv-2.1.0.tar.gz (471 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-7w6579jw/mmcv_e7740665c062471ba050fb1c6a436394/setup.py", line 477, in <module>
          ext_modules=get_extensions(),
        File "/tmp/pip-install-7w6579jw/mmcv_e7740665c062471ba050fb1c6a436394/setup.py", line 186, in get_extensions
          import psutil
        File "/usr/lib/python3/dist-packages/psutil/__init__.py", line 100, in <module>
          from . import _pslinux as _psplatform
        File "/usr/lib/python3/dist-packages/psutil/_pslinux.py", line 26, in <module>
          from . import _psutil_linux as cext
      ImportError: cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) (/usr/lib/python3/dist-packages/psutil/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

 搜索后,说需要重新安装psutil或者升级psutil:pip3 install --upgrade psutil,但又报错

Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Requirement already satisfied: psutil in /usr/lib/python3/dist-packages (5.4.2)
Collecting psutil
  Using cached https://mirrors.aliyun.com/pypi/packages/c5/4f/0e22aaa246f96d6ac87fe5ebb9c5a693fbe8877f537a1022527c47ca43c5/psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (288 kB)
Installing collected packages: psutil
  Attempting uninstall: psutil
    Found existing installation: psutil 5.4.2
ERROR: Cannot uninstall 'psutil'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

 大概意思就是这个库是通过distutils,卸载时无法保证卸载干净,然后就干脆报错不让卸载了,真研究起来还是比较麻烦的。

这个时候直接用大招,pip时添加”--ignore-installed“参数

# 直接pip3 install -U psutil --ignore-installed也可以

python3 -m pip install  -U psutil --ignore-installed

 成功!!!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值