5

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)

2 Answers 2

1

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 
Sign up to request clarification or add additional context in comments.

2 Comments

I can't pip install the dependency bc the patched version is not available on pip. I found a workaround by using --no-deps and then just pip installing all the other dependencies minus the one I didn't want to update.
The patch version doesn't have to be on pypi to install it.
0

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...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.