Python 2 reached end of life in January 2020. NOTE: The Azure CLI installs the version of Python it uses the path of a program: which pythonīecause the file “python” in actually a symbolic link to the actual executable.Īlthough earlier macOS comes with a version of Python, it is Python2, which is now obsolete in favor of python3. The operating system searches for executables in each folder in the PATH, from left to right. But the Python program actually executed is the first one that the operating system finds among folders defined in your PATH system variable defined in ~/.bash_profile or ~/.zshenv. PROTIP: There may be several Python executables installed in different folders. You are good to go with Pipenv if you see in the first response to the type -a python command (but instead of “wilson_mar”, you’ll see your own user name): python3 is /Users/wilson_mar/.pyenv/shims/python3
Python3 is is /usr/local/anaconda3/bin/python
So Homebrew and other installers install to the User-owned /usr/local/ which does NOT require sudo to access.ĭifferent installers install Python in different paths (but instead of “wilson_mar”, you’ll see your own user name): python is /Users/wilson_mar/.pyenv/shims/python PROTIP: The /usr/bin/ folder is owned by the operating system, so elevated sudo priviledges are required to modify files in it (such as “python”). Get a list of the various locations where Python is installed (by various installers): type -a pythonĪ new macOS version would show: python is /usr/bin/python PROTIP: Before installing things, first see what is already installed. The alternative to Pyenv is Conda and MiniConda. Thus, which aws would return: /Users/wilson_mar/.pyenv/shims/aws Competitors This technique is possible because the operating system searches for executables in folders in the PATH from left to right.
That’s achieved by a line at the bottom of your ~/.bash_profile which makes the operating system search in the shims folder for programs: export PATH="$PYENV_ROOT/shims:$PATH" Pyenv uses a technique called “rehashing” so it can switch among multiple versions of Python2 or Python3.Ĭommands for the operating system to execute “python3” are intercepted by a shim executable which passes commands along to the actual Python installation of the desired version. Why? Because I haven’t seen one on the internet. Here is a hands-on “deep dive” tutorial so you better grasp the complexities in a shorter time. In this article I take a carefully crafted narrated tour. Switch between installed versions without resetting your bash session.Dynamically specify the exact Python version you want.Install multiple parallel versions of Python.Install Python in your user space (without need for sudo).Pipenv brings “the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world.” This tutorial describes the different options to install, uninstall, configure, and use various versions of Python with its various packages, all running in a virtual environment also managed by pyenv.