pip: upgrade package without upgrading particular

2019-03-16 06:17发布

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?

2条回答
We Are One
2楼-- · 2019-03-16 07:04

This works and lets you be more precise:

pip install -U django-rosetta Django==1.4
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-03-16 07:05

Create a requirement file requirement.txt containing:

Django==1.4

then

pip install -U django-rosetta -r requirement.txt
查看更多
登录 后发表回答