Reputation: 7359
I'm trying to pip install a library that has a lot of dependencies. I have a patched version of one dependency that I would like not updated when I install the library. How can I prevent this patched dependency from being updated?
(Specifically, I want to pip install fastai
without upgrading my version of torch
, but do install other dependencies required)
Upvotes: 5
Views: 1673
Reputation: 97
As of 2024 (CPython 3.12.2, pip 24.3.1), the Natim's answer does not seem to work. I ran
pip install torch==2.5.0
pip install torchvision
and this automatically upgraded torch to 2.5.1. What worked for me is to pass the --no-deps argument to pip:
pip install torch==2.5.0
pip install torchvision --no-deps
But the problem of this solution is that I may accidently update torch with some other package that uses it as a dependency, in the future...
Upvotes: 0
Reputation: 18132
If you install this dependency before running pip install it won't install it again.
This means to you can install your patched version and then your package:
For instance:
From pypi with another version
pip install requests==2.17.0
pip install kinto
From a Git branch
git clone [email protected]:kennethreitz/requests.git
pip install -e requests
pip install kinto
From a egg or a wheel
wget https://github.com/kennethreitz/requests/archive/v2.21.0.tar.gz
pip install v2.21.0.tar.gz
pip install kinto
Upvotes: 1