

- #DOWNLOAD NEWEST VERSION OF PYTHON FOR MAC INSTALL#
- #DOWNLOAD NEWEST VERSION OF PYTHON FOR MAC SERIES#
- #DOWNLOAD NEWEST VERSION OF PYTHON FOR MAC DOWNLOAD#
With that in mind, I'll install 3.5.9 and 3.8.0: $ pyenv install 3.5.9
#DOWNLOAD NEWEST VERSION OF PYTHON FOR MAC DOWNLOAD#
For now, I stick with the latest of each dot-release (3.5.x or 3.6.x where x is the latest) found on the Python download page. It's a long, overwhelming list that may be helpful to review in the future. There is a way to see all Python versions available from all the different repositories pyenv has access to by running pyenv install -list. Now that pyenv is set up correctly, I want it to have a few different versions of Python that I regularly use. Now that pyenv is in control, we can see it only has the system Python available to it: $ pyenv versionsĪs mentioned above, you absolutely do not want to use this version ( read more on why). You can dive deep into path setting in pyenv's README if you would like to learn more. If you use Bash, change ~/.zshrc to ~/.bashrc. zshrc file only manages zsh instances, so be sure to check what your shell is and edit the associated dotfiles. If you need to double-check what your default shell is, you can run echo $SHELL. Note that I used single quotes with echo so it does not evaluate and expand the commands. Now every time we run a command in zsh, it will use the pyenv version of Python.

Append that same syntax to the ~/.zshrc file: $ echo 'PATH=$(pyenv root)/shims:$PATH' > ~/.zshrc Since zsh is officially macOS's default shell, I'll focus on it.

That export statement (PATH=) will only change for this shell instance, so make it a permanent change, you need to add it to your dotfiles. Now, if you check the version of Python, you'll see it is the one managed by pyenv: $ which python To set up pyenv correctly, you can run the following in Bash or zsh: $ PATH=$(pyenv root)/shims:$PATH If you don't change the path, here is the result: $ which python You must ensure the shell will find the version of Python run by pyenv, not the one installed by default (which is often called the system version). PATH determines where the shell searches for files by the name of the command. In order to use the version of Python through pyenv, it's essential to understand the shell's PATH variable. I could clone and compile it myself from source, but I prefer to manage packages like this through the Homebrew package manager: $ brew install pyenv
#DOWNLOAD NEWEST VERSION OF PYTHON FOR MAC SERIES#
Thankfully, pyenv exists to work around this series of complexities. I would happily talk about why I still think it should.) Installing and setting up pyenv (A note on the above: I know this makes no sense to seasoned Python developer, but it made sense to me at the time. It might seem logical to think the Python package manager pip could install it*, but that wasn't the case: $ pip install python3.5.9ĮRROR: Could not find a version that satisfies the requirement python3.5.9 (from versions: none)ĮRROR: No matching distribution found for python3.5.9Īlternatively, I could have downloaded that version from the official Python website, but how would I run it in on my Mac alongside my existing version of Python? Specifying the version of Python I intend to use every time I run the interpreter (python3.7 or python3.5 for example) seems error-prone at best. Recently, I tried to run a project on macOS that depended on Python 3.5.9, a version that I did not have installed on my system. That makes it important for me to regularly get those updates. Python 3 is developing steadily, and releasing new updates regularly.

In January 2020, Python 2 reached end of life, and only Python 3 will be supported by the language's core maintainers from then forward. Similarly again, different releases are identified by a three-digit number known as a semantic version.įor many years, Python 2 was the commonly used major version of the programming language. They have bugs, fixes, and updates like any of your favorite APIs and any other software. It's a strange concept at first, but programming languages change like any other software. While there are well-documented strategies for package management, there is another step necessary to ensure you are running the version of Python you need when you need it. Managing a local Python development environment continues to be a challenge, even for experienced developers.
