5

I realise that there is already an answer for the question but its for Mac OS X 10.6.4 and the python he installed was from "python.org". My python 2.7 has come built-in in my Mac so how do I remove it? Is there any way of removing it? I have installed a python3.7 from the website and it is working perfectly but 2.7 is also working. I want to remove 2.7 and make it such that when i type "python" in terminal it runs python3.7 and not 2.7.

1
  • You could alias the python command to be python3. Much easier and you'll have the option to use py2.7 if you'll ever need it (usually older py projects) To alias check this Commented Jun 19, 2019 at 4:25

3 Answers 3

20

You don't have to remove python 2.7. You can simply add the command as an alias (you can also add this in your ~/.bash_profile file):

alias python='python3.7' 

Do not remove python 2.7 (default python package), it may damage your operating system.

If you want you can simply use this command (removes the python installed with homebrew):

brew uninstall python 

Refer this question if you really thinking of removing python 2.7. Here is another question which will give you more information.

Sign up to request clarification or add additional context in comments.

2 Comments

Note: If you have multiple versions of Python on your machine and you decide to brew uninstall it, you'll have to specify which version you want brew to remove.
The best advice
2

the 2.7 version of python is a bundle that comes along with the MAC Unix operating system. which means maybe you not using it but there are some pre-loaded programs and dependencies which uses python hence you cannot remove it completely. If you want to use python 3 directly from the terminal's command line just use "python3" in place of "python". this will launch python 3.* what ever you have installed.

Comments

0

A Mac has more Pythons than a Malaysian jungle.

A new Mac M1 has version 2.7 in /System/Library/Frameworks/Python.framework/Versions/2.7

If you use Homebrew to install Vim, it uses /opt/homebrew/Cellar/[email protected], and it warns you if you delete it, Vim won't work.

Meantime, I want to do the introductory tensorflow machine learning course, and it insists on Python 3.8

So in my .bash_profile

alias python='/opt/homebrew/Cellar/[email protected]/3.8.8_1/bin/python3'

alias python3='python'

alias python3.8='python3'

and I deleted all references to Python2.7.

But when I open a new terminal, and run a Python program which does

print(sys.path)

it includes /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7

and tensorflow won't work. The Mac is inserting its own Python into what I want.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.