Can I update to python3.7 from python2.7 in my macOS 10.14.1?

I have macOS 10.14.1. I installed Python3.7 but can see that python2.7 already installed in my os. Can I remove 2.7 and just keep 3.7? Will it affect other apps?


You don't need to remove one in order to install the other. You can have both python 2.7 and python 3 on your Mac. (In fact, python 2.7 is part of the OS and can't really be removed).

You just need to make sure that you invoke the correct one, either by typing python3 on the command line, or using #!/usr/bin/env python3 in scripts.


You should not remove python 2.7 but you can install python 3.7. I suggest you use Anaconda and install python 3.7. After installing 3.7 be sure to create and use virtual environments. There are instructions on the internet on how to use virtual environments.


In the past I would have told never ever to uninstall anything installed as part of MacOS, as this is just calling for troubles. But this is a moot point now because you can't remove anything from /usr/bin anymore. Not in 10.14, not in 10.13 either. Even with sudo you can't. For example:

/usr/bin% sudo mv zprint zprint-bis                                     
mv: rename zprint to zprint-bis: Operation not permitted

The way to go is what you did, I guess. Install python3 in /usr/local which is all yours for the taking. Then modify your PATH so that /usr/local appears before /usr/bin. The standard way to do that on MacOS is to modify /etc/paths. Here is what mine looks like:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

No need to modify your ~/.profile or any other shell startup script. Note that it will only get you the right PATH when running from Terminal. If you need modified PATH to be seen from a GUI app, then please follow the instructions here.