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?

Community
  • 1
  • 1
Aamir Rind
  • 38,793
  • 23
  • 126
  • 164
  • In the example Pip tried to install `Django 1.5`, is this because `Django 1.4` was not installed using pip? – Aamir Rind Jun 20 '13 at 10:16

2 Answers2

22

This works and lets you be more precise:

pip install -U django-rosetta Django==1.4
gordonc
  • 532
  • 4
  • 8
8

Create a requirement file requirement.txt containing:

Django==1.4

then

pip install -U django-rosetta -r requirement.txt
Guillaume
  • 10,463
  • 1
  • 33
  • 47
  • But if i follow this approach it would upgrade rest of the packages (apart from Django) which are in requirements.txt file. – Aamir Rind Jun 20 '13 at 10:26
  • 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. – Guillaume Jun 20 '13 at 10:31
  • Just tested and it will work with `requirements.txt` file if you keep the version number also for every package. – Aamir Rind Jun 20 '13 at 10:45
  • @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? – securecurve Jul 09 '14 at 07:57