简体   繁体   English

如果存在软件包依赖项冲突,如何停止pip安装?

[英]How do I stop a pip install if there are package dependency conflicts?

I did pip install tensorflow-gpu==1.12.3 because my GPU can only support CUDA 9, while the latest tensorflow-gpu==1.14.0 requires a minimum of CUDA 10. One of the package dependencies is tensorboard . 我做了pip install tensorflow-gpu==1.12.3因为我的GPU仅支持CUDA 9,而最新的tensorflow-gpu==1.14.0至少需要tensorboard 。软件包依赖项之一是tensorboard

I want to do pip install tensorflow . 我想做pip install tensorflow However, the latest version warns that a newer version of tensorboard must be installed, then automatically proceeded to uninstall the existing version and install the newer one. 但是,最新版本警告必须安装新版本的tensorboard ,然后自动继续以卸载现有版本并安装新版本。 Is there a way to have pip halt or at least ask for confirmation instead of proceeding on its own in such a situation? 在这种情况下,是否有办法停止点子或至少要求确认,而不是自己继续进行? I'm trying to figure out which is a compatible version of tensorflow that doesn't require newer versions of package dependencies shared with tensorflow-gpu . 我试图弄清楚哪个是tensorflow的兼容版本,不需要与tensorflow-gpu共享的软件包依赖关系的较新版本。

Edit 编辑

ok just to clarify, this isn't a tensorflow-specific question, I'm just using it as an example because I just happen to be doing that right now. 好的,请澄清一下,这不是一个特定于张量流的问题,我只是以它为例,因为我现在恰好正在这样做。

To generalise: I installed an older version of package A, which has a dependency on an older version of package B. I want to install package C, which also has a dependency on package B. However, the latest version of C requires the latest version of B. When I try to install C, it automatically uninstalled the older B and installed the newest version. 概括地说:我安装了较旧版本的软件包A,它依赖于软件包B的旧版本。我想安装软件包C,它也依赖于软件包B。但是,最新版本的C需要最新的软件包。 B版本。当我尝试安装C时,它会自动卸载较旧的B并安装最新版本。 How do I stop it from doing that? 我该如何阻止它呢?

Right now my only workaround is to install a version of C, wait for it to automatically uninstall something, then interrupt the installation of C, and reinstall the version of the dependency package that was uninstalled. 现在,我唯一的解决方法是安装C版本,等待它自动卸载某些内容,然后中断C的安装,然后重新安装已卸载的依赖项软件包的版本。 Then I step down to the next older version C, and repeat. 然后,我下一个下一个较旧的版本C,然后重复。 Basically, a trial and error process. 基本上是一个反复试验的过程。

Is there a more proper and elegant solution? 有没有更合适,更优雅的解决方案? I'm fine with it giving a warning that C requires a newer version of B and then terminating at that point, or prompting for a confirmation before proceeding to uninstall, instead of doing it automatically without asking. 我可以接受警告,警告C要求B的更新版本,然后在该位置终止,或者提示您进行确认,然后再继续进行卸载,而不是自动进行而不进行询问。

I'm using PyCharm's venv, so alternatively I'm also fine if there's a way to revert the latest change to the environment ie uninstall C and whatever new dependency packages that's installed, reverting to the list of installed packages before I executed pip install C . 我正在使用PyCharm的venv,因此,如果有一种方法可以将对环境的最新更改还原,即卸载C和已安装的所有新依赖包,并在执行pip install C之前还原到已安装的包列表,那么我也很好。 。

Hopefully that doesn't sound too convoluted. 希望这听起来不会太令人费解。 😅 😅

I have never done any work with tensorflow so I can't help you with that part, but I can suggest you using virtual environments when testing out stuff and not risking breaking system Python or upgrading packages you want at specific version. 我从未在tensorflow做过任何工作,因此我无法为您提供帮助,但是我建议您在测试内容时使用虚拟环境,并且不要冒险破坏系统Python或升级特定版本所需的软件包。

python -m venv env to create virtual environment called env . python -m venv env创建名为env虚拟环境。 source env/bin/activate to make the virtual environment active and deactivate to leave it. source env/bin/activate使虚拟环境处于活动状态,并使其deactivate以使其离开

Regarding the overwriting old packages, I haven't found options for promting installing new version nor an option to ignore requirements for a certain package. 关于覆盖旧软件包,我没有找到提示安装新版本的选项,也没有找到忽略某个软件包要求的选项。 This is probably because developers can specify which version of dependencies are required and thus if pip finds outdated package, the package you wish to instal would probably not be usable with it. 这可能是因为开发人员可以指定所需版本的依赖项,因此,如果pip找到了过时的软件包,则您希望安装的软件包可能无法使用。

However, you might try installing the newest version of tensorflow and let it install requirements it needs and then simply uninstall them using pip uninstall PACKAGE-NAME and install the version you wish with pip install PACKAGE-NAME==xxx . 但是,您可以尝试安装最新版本的tensorflow并安装所需的要求,然后只需使用pip uninstall PACKAGE-NAME install pip uninstall PACKAGE-NAME卸载它们,然后使用pip install PACKAGE-NAME==xxx安装所需的版本。

Also, here is a guide that explains installation of tensorflow with CUDA 9 . 另外, 这是一个指南,说明使用CUDA 9安装tensorflow It seems that they are using version 1.8 for CUDA 9.2 and 1.7 for CUDA 9.1. 看来他们正在使用1.8版的CUDA 9.2和1.7版的CUDA 9.1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM