Can I prevent pip from downgrading packages implicitly?

I have Django 1.10.5 installed in my python virtual environment.

When I install djblets into my virtualenv with pip install djblets

unfortunately Django is implicitly downgraded to version 1.8.17 along the way. It disrupts my environment.

Is there something I could do to prevent this? I certainly didn't ask, everything is all right on my part. But I really had to.

djblets version 0.9.6 doesn't even get installed because it depends on the pillow refusing to build. It's all just broken and killing my environment along the way, because the deletion happens first.

All I can think of is trying to install in a separate but identical virtual environment and see what happens. Like a dry run.

Now I have to install my environment from scratch. Am I missing something, or is this the way it is?

+3


source to share


1 answer


You need to install both packages at the same time (with only one command) and give the package version number

pip install django==1.10.5 djblets

      

Generally, instead of installing packages one by one, I would recommend using a requirements.txt

.

In your example, your file requirements.txt

will have (at least):

django==1.10.5
djblets==1.0.2

      

Then you can install all packages in one go using the option :[--requirements, -r]

pip

pip install -r requirements.txt

      

Why?

Unless explicitly stated, it pip

will try to install the best dependencies for a given module (those described in the package itself), and this may even downgrade the package!



Often times, you won't have a choice to downgrade the NOR service pack to make it work. Therefore, it is very important to put a version number in every package you need to avoid regression!

Tips

(OK, because the option update

only works for packages with an unspecified version number)

But this method is only valid if you already have all dependencies installed.

Bonus

To answer the question you did not ask, you can take a "snapshot" of all your packages if you are afraid of doing wrong manipulation using freezing beer

pip freeze > requirements.txt

      

+1


source







All Articles