10

My question is very much similar to this question. But It differs in a way that if i am installing some package i only want to disable upgrade for a particular dependency not for all dependencies. I know there is a flag --no-deps but it will exclude all dependency rather i just want to exclude one.

Here is a scenario:

Here are django-rosetta dependencies in latest build:

install_requires=[ 'six >=1.2.0', 'Django >= 1.3' ] 

Now i want to upgrade rosetta pip install -U django-rosetta. But it tried to download and install Django 1.5 because in rosetta dependency Django >= 1.3 is required (and i don't want it to do this as Django 1.4 is already installed) I only want it to upgrade six package if there is any.

--no-deps flag will not work as it will exclude six package also. Also I am not using virtual environment. Any suggestions please?

1
  • In the example Pip tried to install Django 1.5, is this because Django 1.4 was not installed using pip? Commented Jun 20, 2013 at 10:16

2 Answers 2

22

This works and lets you be more precise:

pip install -U django-rosetta Django==1.4 
Sign up to request clarification or add additional context in comments.

Comments

8

Create a requirement file requirement.txt containing:

Django==1.4 

then

pip install -U django-rosetta -r requirement.txt 

4 Comments

But if i follow this approach it would upgrade rest of the packages (apart from Django) which are in requirements.txt file.
Well, maybe I didn't understood your question, but you were asking for a way to prevent upgrading some specific package (Django) while upgrading everything else... what I'm saying is the requirement file can be use to block those specific packages to be upgraded and let pip upgrade others.
Just tested and it will work with requirements.txt file if you keep the version number also for every package.
@Guillaume a similar question, how to avoid installing some sub-dependancy, for example, I want to install PyYAML which depends on lxml, which will be automatically installed when installing PyYAML .. now, I want to avoid installing lxml and I will install it manually, either before or after .. how to do this?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.