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.

Nischaya Sharma
  • 431
  • 2
  • 6
  • 16
  • 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](https://stackoverflow.com/questions/8967843/how-do-i-create-a-bash-alias) – clamentjohn Jun 19 '19 at 04:25

3 Answers3

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.

R4444
  • 2,016
  • 2
  • 19
  • 30
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.

vaibhav krishna
  • 267
  • 2
  • 4
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/python@3.9, 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/python@3.8/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.

rodmclaughlin
  • 371
  • 3
  • 8