项目场景及问题描述
不联网环境用pip直接安装下载好的指定版本的.whl第三方库,会存在与现有已安装的包版本冲突的问题,出现报错:
ERROR: Cannot unistall ‘llvmlite’. 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.
以安装包llvmlite-0.38.1版本为例,系统已有0.31.0版本
具体如下:
Installing collected packages: llvmlite
Attempting uninstall: llvmlite
Found existing installation: llvmlite 0.31.0
ERROR: Cannot unistall 'llvmlite'. 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.
原因分析:
出现这种问题的原因有可能是网络问题,国外镜像连接失败导致(这种情况可以指定下载地址,解决方案将在文章末尾给出)。由于我的环境不联网,主要还是版本冲突问题,因此如果确定要替换指定版本,不会影响其他代码依赖的环境,可以使用暴力解决方案,如下。
解决方案:
在pip指令后加上 --ignore-installed
表示忽略已经安装的库,安装指定版本。
引起报错的pip指令如下:
pip install llvmlite-0.38.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
修改后无报错的指令如下:
pip install llvmlite-0.38.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl --ignore-installed
执行后安装成功:
Processing ./llvmlite-0.38.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Installing collected packages: llvmlite
Successfully installed llvmlite-0.38.1
如果是因为网络、国外镜像连接失败问题,参考以下解决方案
pip 安装第三方库时各种报错It is a distutils installed project and thus we cannot accurately determine