简体   繁体   中英

pip reinstall pkg and install dependencies that are not installed, but not install dependencies that are already installed?

I know I can use

pip --ignore-installed --no-deps

to reinstall a pkg without dependencies; however, if a dependency is missing, it won't get installed anyway. How can I reinstall a pkg and only dependencies that are not installed, but ignore dependencies that have been already installed?

Just for people who stumble across this question later -- If I understand your question correctly, this functionality was added a while ago. I would have to look up when it made it into pip. The upgrade strategy 'only-if-needed' is the current default so that could be left out BUT, as a pythonista, explicit is better than implicit :)

pip install --upgrade --upgrade-strategy only-if-needed <package-name>

Essentially, what this is doing is upgrading the package and it will reinstall dependencies if needed. this will only install missing or outdated dependencies. It will not upgrade dependencies that already satisfy the package requirements even if there is a newer version that also satisfies the package requirments .

You can read more about this functionality in the pip documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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