Update a package: pip install --upgrade To update installed packages to the latest version, run pip install with the --upgrade or -U option.
pip is Python's official package manager and is a recommended method for installing, upgrading, and uninstalling the Python packages.
The best way I've found is to run this command from terminal
sudo pip install [package_name] --upgrade
sudo
will ask to enter your root password to confirm the action.
Note: Some users may have pip3 installed instead. In that case, use
sudo pip3 install [package_name] --upgrade
You might want to look into a Python package manager like pip. If you don't want to use a Python package manager, you should be able to download M2Crypto and build/compile/install over the old installation.
To automatically upgrade all the outdated packages (that were installed using pip), just run the script bellow,
pip install $(pip list --outdated | awk '{ print $1 }') --upgrade
Here, pip list --outdated
will list all the out dated packages and then we pipe it to awk, so it will print only the names.
Then, the $(...)
will make it a variable and then, everything is done auto matically. Make sure you have the permissions. (Just put sudo
before pip if you're confused)
I would write a script named, pip-upgrade
The code is bellow,
#!/bin/bash
sudo pip install $(pip list --outdated | awk '{ print $1 }') --upgrade
Then use the following lines of script to prepare it:
sudo chmod +x pip-upgrade
sudo cp pip-upgrade /usr/bin/
Then, just hit pip-upgrade
and voila!
pip list --outdated
You will get the list of outdated packages.pip install [package] --upgrade
It will upgrade the [package]
and uninstall the previous version.To update pip:
py -m pip install --upgrade pip
Again, this will uninstall the previous version of pip and will install the latest version of pip.
pip install package_name -U
pip install $(pip list --outdated --format=columns |tail -n +3|cut -d" " -f1) --upgrade
for i in $(pip list --outdated --format=columns |tail -n +3|cut -d" " -f1); do pip install $i --upgrade; done
I think the best one-liner is:
pip install --upgrade <package>==<version>
Open Command prompt or terminal and use below syntax
pip install --upgrade [package]==[specific version or latest version]
For Example
pip install --upgrade numpy==1.19.1
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