How to Install pyenv on MacOS Without Homebrew

Sure Homebrew is great, but you can still have a robust Python environment on Mac without it

Sarah Noles
Jun 3 · 3 min read

I recently found myself setting up a new MacBook Pro for Python development. There’s plenty of documentation on the internet for installing pyenv on Mac, but they seem to all focus around installing via Homebrew. Well, that wasn’t an option for me, so below I’ve documented the steps I took to install pyenv without Homebrew.


Run the following command to install pyenv.

% curl -L | bash

If pyenv is still not in your path and you’re on the latest version of MacOS, run the following commands in Terminal.

% PYENV_ROOT="${HOME}/.pyenv"% echo "export PATH=\"${PYENV_ROOT}/bin:\$PATH\"" >> ~/.zshrc
% echo "eval \"\$(pyenv init -)\"" >> ~/.zshrc
% echo "eval \"\$(pyenv virtualenv-init -)\"" >> ~/.zshrc

My Specs

I used this method to install pyenv on a 2020 MacBook Pro running macOS Catalina.

Using pyenv-installer

If you don’t wish to use Homebrew for your pyenv installation, the developer of the project also provides the pyenv-installer project. This provides an install script with a simple bash command that handles the installation for you.

The documentation for this project says to run curl | bash, but this gave me a certificate error.

There are two ways around this. The path of least resistance is to use the -k flag (don’t check certificates) on the curl command. The more secure option is to just call the command the script redirects you to — which points to GitHub and has a secure certificate. To do this instead, run:

% curl -L | bash

This command downloads the installer file and pipes the installer file to bash. In other words, it runs the file in a bash shell.

Adding pyenv to a Path

Unfortunately, the installer command we used doesn’t successfully add pyenv to your path. This is due to the command piping to the bash shell. Effective in macOS Catalina, Apple has started using Zsh (pronounced Z Shell) instead of bash as the default terminal (source). So when we pipe the command to bash, it doesn’t know to update the configuration for Zsh instead.

An easy way to remedy this situation would just be to not pipe the command to bash and instead run it in Zsh. The script does have built-in logic to update the Zsh profile if it can appropriately detect that it’s running. However, if you’re like me and have already run the installer, the steps below will remedy the situation and add pyenv to the path.

To add to the Zsh path, we need to run the following commands to add pyenv to the shell’s configuration file.

% PYENV_ROOT="${HOME}/.pyenv"% echo "export PATH=\"${PYENV_ROOT}/bin:\$PATH\"" >> ~/.zshrc
% echo "eval \"\$(pyenv init -)\"" >> ~/.zshrc
% echo "eval \"\$(pyenv virtualenv-init -)\"" >> ~/.zshrc

This will add the program to your path variable. From here, you can restart your terminal and begin using pyenv.

Start Using pyenv

With pyenv installed, I used it to install the latest version of Python. At the time of this writing that’s Python 3.8.3. To install, I ran:

% pyenv install -v 3.8.3

At this point, if you check your Python version, you’ll still see the system-default version. On my system, this looked like:

% python -V
Python 2.7.16

We have to tell the system which version of Python we want to use. First, we can list the Python versions available via pyenv, and then we can tell pyenv to set the global version to the preferred version. In this case that’s 3.8.3.

% pyenv versions
* system (set by /Users/snolesmuth/.pyenv/version)
% pyenv global 3.8.3% python -V
Python 3.8.3

Once we tell Python to use the newer version, we can run the Python command as normal, but pyenv will redirect to the version we specified.


Pyenv is an incredibly powerful tool allowing you to use separate Python installs for different users, projects, or folders as you need to without relying on macOS’s incredibly out-of-date default version.

Better Programming

Advice for programmers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store