Pip:强制安装忽略依赖项

有没有办法强制安装一个pip python包,忽略它所有不能满足的依赖关系?

(我不在乎这样做有多“错误”,我只需要这样做,抛开任何逻辑和推理……)

222769 次浏览

pip有一个--no-dependencies开关。你应该利用它。

有关更多信息,运行pip install -h,在那里你会看到这一行:

--no-deps, --no-dependencies
Ignore package dependencies

当我尝试用pip (pip install librosa)安装librosa包时,出现了这个错误:

ERROR: Cannot uninstall '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,但pip uninstall不能删除它。因此,我通过以下代码使用了pipignore功能:

pip install librosa --ignore-installed llvmlite

实际上,你可以使用这个规则来忽略你不想考虑的包:

pip install {package you want to install} --ignore-installed {installed package you don't want to consider}

试试下面的方法:

pip install --no-deps <LIB_NAME>

pip install --no-dependencies <LIB_NAME>

pip install --no-deps -r requirements.txt

pip install --no-dependencies -r requirements.txt