Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I upgrade specific packages using pip and a requirements file?

I'm using pip with a requirements file, in a virtualenv, for my Django projects. I'm trying to upgrade some packages, notably Django itself, and I'm getting an error about source code conflicts:

Source in <virtualenv>/build/Django has version 1.2.3 that conflicts with Django==1.2.4 (from -r requirements/apps.txt (line 3))

That's after updating the version number of Django from 1.2.3 to 1.2.4 in my requirements file. I'm using this command to actually do the upgrade:

pip --install --upgrade -E `<virtualenv dir`> --requirement `<requirements file`> 

I can't find any flag that triggers a total package re-download. I even tried running an uninstall command first, and then the install, but no dice. Am I missing something?

like image 627
gcaprio Avatar asked Dec 27 '10 00:12

gcaprio


People also ask

How do I upgrade pip packages?

Update a package: pip install --upgrade To update installed packages to the latest version, run pip install with the --upgrade or -U option.

Can I upgrade pip in requirements txt?

No. Your requirements file has been pinned to specific versions. If your requirements are set to that version, you should not be trying to upgrade beyond those versions. If you need to upgrade, then you need to switch to unpinned versions in your requirements file.


1 Answers

I ran the following command and it upgraded from 1.2.3 to 1.4.0

pip install Django --upgrade 

Shortcut for upgrade:

pip install Django -U 

Note: if the package you are upgrading has any requirements this command will additionally upgrade all the requirements to the latest versions available. In recent versions of pip, you can prevent this behavior by specifying --upgrade-strategy only-if-needed. With that flag, dependencies will not be upgraded unless the installed versions of the dependent packages no longer satisfy the requirements of the upgraded package.

like image 104
JoeyG Avatar answered Oct 22 '22 12:10

JoeyG