How do i uninstall python 2 and install python 3?

Python is uninstalled differently in Windows and Mac.

Windows

To uninstall Python from Windows, follow these steps:

  1. Navigate to Control Panel.

  2. Click “Uninstall a program”, and a list of all the currently installed programs will display.

  3. Select the Python version that you want to uninstall, then click the “Uninstall” button above the list – this has to be done for every Python version installed on the system.

Mac

For Python 3 and above, first, perform the following steps:

  1. Go to the Finder.

  2. Click on Applications in the menu on the left.

  3. Find the Python folder with the version number you want to uninstall, right-click it, and select “Move to Trash”.

Removing additional files from the Terminal

Moving the Python application to trash will not remove Python entirely. Furthermore, a built-in Python distribution may not appear in the Applications folder. So we’ll have to use the Terminal to uninstall it manually.

First, open the Activity Monitor and close all processes related to Python in the Memory tab. One such process is the Python Launcher. Now we can proceed to the Terminal.

  1. Open the Terminal and navigate to your Library folder from your root directory:
$ [base] Username:~ cd Library

Here, you can list the current folders in your Library using the ls command. Look for a folder named Python. Remove this folder with super-user privileges:

sudo rm -rf Python

Note: The operation requires your password in order to be completed.

Additionally, three more main directories have to be handled in order to remove Python. Move back to your root user directory and perform the following commands:

sudo rm -rf “/Applications/Python”
sudo rm -rf /Library/Frameworks/Python.framework
sudo rm -rf /usr/local/bin/python

Note: We do not recommend this step for novice Mac users. The way Python files are distributed in your Library and cache may differ based on your use, and so, extra files may have to be deleted which you can search for in the Finder or manually in the terminal.

I have successfully installed python 3.3 on Ubuntu 12.10. Since I don’t need multiple versions of python, I want to remove the existing python 2.7. When I try to do that, using

sudo apt-get remove python2.7

Ubuntu warns me that there are tons of system dependent components which will also be removed. It looks really scary.

So, is there a way to remove python 2.7 without removing the system dependent components, or can I direct those dependents to use python 3.3?

TRiG

1,8801 gold badge18 silver badges39 bronze badges

asked Jul 1, 2013 at 13:42

2

You can't.

From the Ubuntu wiki / Python:

Longer term plans [e.g. 14.04]

Move Python 2 to universe, port all Python applications in main to Python 3. We will never fully get rid of Python 2.7, but since there will also never be a Python 2.8, and Python 2.7 will be nearly 4 years old by the time of the 14.04 LTS release, it is time to relegate Python 2 to universe.

This means that a lot of base packages have hard dependencies on 2.7 and it will still take a lot of time tot get things migrated. Note that Python 3 has numerous backwards incompatible changes -- it's not a regular package upgrade.

If you really want to get rid of Python 2.7, you'll have to wait for the 14.04 release, but there's no guarantee.

Taymon

7332 gold badges8 silver badges19 bronze badges

answered Jul 1, 2013 at 13:49

gertvdijkgertvdijk

65.4k31 gold badges182 silver badges279 bronze badges

4

Came here in 2019 because I develop in Python3 by default and came to the same conclusion as OP after seeing what'd be removed after running apt purge python

Since what I really wanted was to call Python3 with just python, I ran

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python

This way, if Python2.7 is still needed, it can be called explicitly with python2.7 while simply calling python will default to Python3 because of the symbolic link.

I don't have any bash level scripts that call python2.7 with python so this change wouldn't be disruptive - while other systems would need their scripts adjusted accordingly if they did.

The main barrier to a distribution switching the python command from python2 to python3 isn't breakage within the distribution, but instead breakage of private third party scripts developed by sysadmins and other users.

- The "python" Command On Unix-Like Systems

This answer isn't a direct response to OP, but as someone who had a similar question this is the functionality I was looking for when I was thinking of removing 2.7. Rather than delete, just prioritize which one gets to use python.

answered May 29, 2019 at 21:44

saniboysaniboy

2812 silver badges5 bronze badges

11

You can't, and you don't really want to.

Python changed drastically between 2.7 and 3.0, and broke backward compatibility. Python scripts that were written for 2.7, which are used to support a large amount of the system's infrastructure, won't necessarily work properly with Python 3.x. Those scripts need to be updated to work with the new version, and until that happens, you'll need to keep Python 2.7 around.

This is why you notice such a large number of dependencies on the old Python - the system depends on it. Besides, there's no harm in having both versions of Python installed on the same system. And you may come across applications in the future that still use Python 2.7, so keeping it around is a good idea.

answered Jul 6, 2013 at 14:32

How do I install Python 3 on Python 2?

How to install Python 2.7 and 3.6 in Windows 10 [add python PATH].
Download python 2.7. Go to www.python.org/downloads and click on 'Download Python 2.714”. ... .
Install python 2.7. When download is finished click to install. ... .
Download python3. ... .
Add python27 and python3 PATH. ... .
Change executables names. ... .
TEST Both Python versions..

How do I uninstall old versions of Python?

Uninstalling Older Python Versions.
Go to Control Panel and select Add or Remove Programs..
Assuming you have an older version X.Y installed, scroll through the list of programs, and for each Python X.Y package that has been installed, select it in the list and click Remove..

Can you have Python 2 and 3 installed?

We can have both Python 2 and Python 3 installed on any Windows or Linux device. We can either create different environments on different IDEs to use the versions separately or use the following ways to run them using the command prompt.

Chủ Đề