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?
Update a package: pip install --upgrade To update installed packages to the latest version, run pip install with the --upgrade or -U option.
How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1.
Pip relies on package authors to stipulate the dependencies for their code in order to successfully download and install the package plus all required dependencies from the Python Package Index (PyPI).
this will automatically upgrade all packages from requirements. txt (make sure to install pip-tools using pip install command).
Automate your Dependencies by installing pipupgrade in your CI workflow. Zero Dependencies! Check out installation for more details. Upgrades all the packages across all detected pip environments. Upgrades pipupgrade. Upgrades all the packages within the defined pip environment.
Doing just pip install without --upgrade does not fix any broken dependencies. And with --upgrade then it goes to the latest version (so not minimal changes I would want). Is there some reason you can't do something equivalent to: Aside: current default upgrade strategy is only-if-needed.
When I use pip install -U, it tries to upgrade all the packages, and even uninstalls and re-installs the same version of a dependency package when there isn't a new version available. I also tried pip install -U --no-deps but that seems equivalent to a regular install instead of an upgrade. Is there a combination of flags that will do what I want?
UPDATE (thanks to @Jether's comment): If you're using the latest version of pip, then updating dependencies only when necessary is now the default behavior, and you don't need to do anything special! The answer below outlines the steps for older versions of pip (which also works for newer versions if you want to be portable).
This works and lets you be more precise:
pip install -U django-rosetta Django==1.4
Create a requirement file requirement.txt
containing:
Django==1.4
then
pip install -U django-rosetta -r requirement.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With