- How to completely uninstall python 2.7.13 on Ubuntu 16.04
- 6 Answers 6
- How to Install Latest Python on Linux Mint 21
- How to Install Latest Python on Linux Mint 21
- How to Uninstall Python from Linux Mint 21
- Conclusion
- About the author
- Syeda Wardah Batool
- Uninstall Python in Ubuntu 22.04
- Prerequisites
- Python Major Releases
- Method 1: Removing Python Using APT
- Step 2: Uninstalling Python
- Optional: Remove All Python Packages
- Method 2: Removing Python from the Source
- Method 3: Removing PyPy
- Bonus: Removing PIP
- Conclusion
- About the author
- Sidratul Muntaha
How to completely uninstall python 2.7.13 on Ubuntu 16.04
I installed Python 2.7.13 on Ubuntu 16.04 according to this guide, and it became the default version as an alternative to the version 2.7.12. But, I wanted to completely remove Python 2.7.13 and return back to the version 2.7.12 as the default version since the pip command does not work with the following error.
bash: /usr/local/bin/pip: /usr/bin/python: bad interpreter: No such file or directory
Could you please help me how to completely remove Python 2.7.13 from Ubuntu 16.04? Otherwise, could you please suggest how to fix the above error?
before doing anything else i suggest you run $ sudo apt install —reinstall python python-apt python2.7-minimal ; ubuntu relies on a working python2 installation! and your question might be better suited here: askubuntu.com
6 Answers 6
# Remove python2 sudo apt purge -y python2.7-minimal # You already have Python3 but # don't care about the version sudo ln -s /usr/bin/python3 /usr/bin/python # Same for pip sudo apt install -y python3-pip sudo ln -s /usr/bin/pip3 /usr/bin/pip # Confirm the new version of Python: 3 python --version
In my case, instead of sudo apt purge -y python2.7-minimal this sudo apt purge python2.7-minimal worked!! But after pressing Enter key I have to type Yes, do as I say! N.B. I’m using this in Linux Mint 19.3 not Ubuntu. Thanks @Benoit Mrx
Yes!! But simple it did not word using -y!! Idk why but it worked only giving permission by retyping the confirm string Yes, do as I say!
caution : It is not recommended to remove the default Python from Ubuntu, it may cause GDM(Graphical Display Manager, that provide graphical login capabilities) failed.
To completely uninstall Python2.x.x and everything depends on it. use this command:
sudo apt purge python2.x-minimal
As there are still a lot of packages that depend on Python2.x.x. So you should have a close look at the packages that apt wants to remove before you let it proceed.
Thanks, I hope it will be helpful for you.
try following to see all instances of python
whereis python which python
Then remove all instances using:
sudo apt autoremove python
repeat sudo apt autoremove python(for all versions) that should do it, then install Anaconda and manage Pythons however you like if you need to reinstall it.
can’t uninstall in a such way. anyway it’s remain in the system. sudo apt autoremove python Reading package lists. Done Building dependency tree Reading state information. Done Package ‘python’ is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded. then again: sudo apt remove python2.7 then: python —version output: Python 2.7.12
this command removed some of the dependencies of my GUI and made my ubuntu-desktop stop working, this also removed google-chrome-stable and another packages. I really don’t know why I run it, heheh
If I’m not wrong autoremove will remove the packages or dependencies which are no longer needed in the environment.
sudo apt purge python2.7-minimal
Sometimes you need to first update the apt repo list.
sudo apt-get update sudo apt purge python2.7-minimal
This is what I have after doing purge of all the python versions and reinstalling only 3.6.
root@esp32:/# python Python 3.6.0b2 (default, Oct 11 2016, 05:27:10) [GCC 6.2.0 20161005] on linux Type "help", "copyright", "credits" or "license" for more information. >>> root@esp32:/# python3 Python 3.8.0 (default, Dec 15 2019, 14:19:02) [GCC 6.2.0 20161005] on linux Type "help", "copyright", "credits" or "license" for more information.
Also the pip and pip3 commands are totally f up:
root@esp32:/# pip Traceback (most recent call last): File "/usr/local/bin/pip", line 7, in from pip._internal.cli.main import main File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60 sys.stderr.write(f"ERROR: ") ^ SyntaxError: invalid syntax root@esp32:/# pip3 Traceback (most recent call last): File "/usr/local/bin/pip3", line 7, in from pip._internal.cli.main import main File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60 sys.stderr.write(f"ERROR: ") ^ SyntaxError: invalid syntax
I am totally noob at Linux, I just wanted to update Python from 2.x to 3.x so that Platformio could upgrade and now I messed up everything it seems.
How to Install Latest Python on Linux Mint 21
Python is a user-friendly high-level and object-oriented programming language that can be easily interpreted. This general-purpose language is famous among users for simple coding projects to complex scripts including Artificial Intelligence and machine learning scripts. It has easily understandable syntax for coding even for the beginners.
Although it is easy to understand, it can perform complex algorithms and can handle huge amounts of data. Python language was designed in a way that it can be extended by adding more modules to the existing ones.
How to Install Latest Python on Linux Mint 21
The latest version of Python can be installed via an external PPA repository. For this, few steps should be followed carefully:
Open the terminal and update apt packages using command:
Execute the mentioned command to install prerequisite dependencies of Python:
Next step it to add PPA repository to the Linux Mint base repository (as it is external repository, so we need to add it first):
As all the dependencies and external repository are installed on Linux Mint 21. Now we can download Python on system by running the following command:
Use the version command to verify if python is installed or not:
How to Uninstall Python from Linux Mint 21
To remove Python from Linux Mint 21 system, the following would be use:
As we have added a PPA repository to the system before downloading Python. So, you can also remove it from system:
Conclusion
This article has focused on how to install an updated version of Python on Linux Mint 21. Python is a highly recommended interpreted language used for various purposes. It can create small projects to large scripts like machine learning and AI with understandable syntax. It was designed in a way that it can be extended by adding more modules to the existing ones.
About the author
Syeda Wardah Batool
I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.
Uninstall Python in Ubuntu 22.04
Python is one of the most popular programming languages. It’s an interpreted general-purpose programming language with an emphasis on simplicity. Because of its versatility, Python is used for various purposes: web development, data analysis, artificial intelligence, and much more.
In this guide, we will have a look at uninstalling Python in Ubuntu 22.04.
Prerequisites
To follow this guide, you need the following components:
- A properly-configured Linux system. Learn more about setting up an Ubuntu virtual machine on VirtualBox.
- Access to a non-root user with sudo privilege. Check out the article on using sudoers to manage the sudo privilege.
Python Major Releases
As of now, the two major versions of Python are:
Python 2 received its last update (v2.7.18) on April 20, 2020. It’s been mostly phased out in favor of Python 3. This move, however, caused a major uproar in the community. Python 2 was so popular that the EOL had to be pushed multiple times into the future.
Although deprecated, you may still come across some Python 2 installations for compatibility reasons. By default, Ubuntu comes with installed Python 3.
Method 1: Removing Python Using APT
Step 1: Finding the Installed Python Package
Run the following commands:
- We ask the Python executable to print its version.
- Ubuntu 22.04 comes with pre-installed Python 3. So, the first command returns a version number.
- Ubuntu 22.04 doesn’t come with pre-installed Python 2. So, the expected result is an error. However, if the command returns a version number, Python 2 is later installed.
On Debian/Ubuntu, the core Python packages are as follows:
Step 2: Uninstalling Python
Now that we know what Python version is currently installed on the system, we can start to work on uninstalling them.
To remove Python 2, run the following command:
To remove Python 3, run the following command:
Optional: Remove All Python Packages
Removing all the Python-related packages is generally not recommended since various parts of the system depend on them. If you wish to proceed, ensure that you backed up all your important data.
To remove all the Python packages from the system, run the following command:
- The APT package manager looks for packages that match the given regular expression (*python*). The matching packages are marked for removal.
- APT also marks the dependencies of those packages for removal.
Method 2: Removing Python from the Source
If Python was compiled and installed from its source code, APT won’t be able to recognize the installation. In that case, the uninstallation process will be different.
Assuming you still have the source directory which contains the compiled Python package, run the following commands:
If you removed the source directory, you could try removing the installed libraries and binaries manually:
Note that this is meant to be the last resort. It may lead to corrupted and broken configurations throughout the system.
Method 3: Removing PyPy
PyPy aims to be a replacement for CPython (the default Python implementation). It’s built with RPython which was simultaneously developed with it. The key advantage to using PyPy other than CPython is performance. Although it’s an implementation of Python, certain differences can impact compatibility. Learn more about PyPy.
Similar to the classic Python, PyPy also has two major releases:
To install PyPy, run the following commands:
Similarly, to uninstall PyPy, run the following commands:
Bonus: Removing PIP
PIP is the de-facto standard package manager for Python packages/modules. By default, it’s configured to use the Python Package Index as the source of packages. Starting from Python 3 (v3.4 and later), PIP comes pre-installed with Python 3. The term “PIP” is a recursive acronym for “PIP Installs Packages”. Learn more about PIP.
Similar to the Python major releases, PIP has unique versions for both Python 2 (python-pip) and Python 3 (python3-pip).
If you removed all the Python packages, PIP is also uninstalled by default. However, if you desire to specifically uninstall PIP, run the following commands:
Conclusion
We demonstrated the multiple ways of removing Python from Ubuntu 22.04. We demonstrated uninstalling both CPython and PyPy from the system using APT. We also discussed uninstalling Python if it is installed from the source code.
Need to reinstall Python? Check out this guide on installing Python on Ubuntu 22.04. Interested in starting your journey with Python? The following guide features 30 example scripts to get started. The Python sub-category also contains numerous guides on various aspects of Python programming.
About the author
Sidratul Muntaha
Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.