解决pip装包报错ERROR: Cannot unistall ‘llvmlite‘. It is a distutils installed project and thus we cannot..

在不联网环境中使用pip尝试安装已下载的llvmlite特定版本(0.38.1)时,遇到与已安装版本(0.31.0)冲突的问题。通过添加--ignore-installed参数,可以忽略已安装的库,成功安装指定版本的llvmlite,避免部分卸载的错误。此外,若因网络问题导致安装失败,可以指定下载地址来解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目场景及问题描述

不联网环境用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值