Python Newbie here. I just bought a new Mac that came with Python 2.7. I'm using the older version of Python for a class so I need to keep it. I want to install the latest version of Python, 3.6, side by side the older version. The instruction I found online were either outdated or confusing. Can anyone point me in the right direction?
You can use brew to install python3.
$ brew install python3
$ python # to start the python 2.7
$ python3 # to start the python 3
This is the simplest way to get started with python 3 on macOS.
if you download anaconda, a very common download for python development, you get a great package manager and a very easy way to create sandboxed environments. After downloading anaconda (for your current Python, so 2.7), you can open up your terminal and enter:
conda create my_new_env_name python=3.6
that will create a new sandboxed environment with python3.6. to use that environment, enter in your shell
source active my_new_env_name
now if you enter python
from the shell you're in python3.6, or you can run python somefile.py
from the shell to run it in python3.6
This is a great way to maintain and manage different versions of libraries on your system as well. For example, if you need an old version of a specific Python library for a particular project, but don't want to downgrade that library for all your Python code.
More on managing conda environments at the documentation page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With