I'm running Ubuntu 9:10 and a package called M2Crypto is installed (version is 0.19.1). I need to download, build and install the latest version of the M2Crypto package (0.20.2).
The 0.19.1 package has files in a number of locations including (/usr/share/pyshared and /usr/lib/pymodules.python2.6).
How can I completely uninstall version 0.19.1 from my system before installing 0.20.2?
In Juptyer notebook, a very simple way is
!pip install <package_name> --upgrade
So, you just need to replace with the actual package name.
Get all the outdated packages and create a batch file with the following commands pip install xxx --upgrade for each outdated packages
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
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.
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
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 install pipupgrade
$ pipupgrade --latest --interactive
pipupgrade helps you upgrade your system, local or packages from a requirements.txt
file! It also selectively upgrades packages that don't break change. Compatible with Python2.7+, Python3.4+ and pip9+, pip10+, pip18+.
NOTE: I'm the author of the tool.
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
How was the package originally installed? If it was via apt, you could just be able to do apt-get remove python-m2crypto
If you installed it via easy_install, I'm pretty sure the only way is to just trash the files under lib, shared, etc..
My recommendation in the future? Use something like pip to install your packages. Furthermore, you could look up into something called virtualenv so your packages are stored on a per-environment basis, rather than solely on root.
With pip, it's pretty easy:
pip install m2crypto
But you can also install from git, svn, etc repos with the right address. This is all explained in the pip documentation
pip install -U $(pip list --outdated | awk 'NR>2 {print $1}')
Source: Stackoverflow.com