
You can verify that the virtual environment is active by running: which python This will activate the myenv virtual environment, so any commands you run will use the version of Python installed in the virtual environment. HUMAN NOTE: If you see the error Failed to activate virtualenv then ensure you set eval "$(pyenv virtualenv-init -)" and then opened a new window or ran source ~/.bash_rc You can replace myenv with whatever name you want.Īfter creating the virtual environment, you can activate it with: pyenv activate myenv This will create a new virtual environment called myenv based on Python 3.10.0. Once pyenv-virtualenv is installed, you can create a new virtual environment by running the following: pyenv virtualenv 3.10.0 myenv You can install it using Homebrew with the following command: brew install pyenv-virtualenv That’s it! You’ve now set up Python 3.10.0 on your Mac!įirst, make sure you have pyenv-virtualenv installed. HUMAN NOTE: You need to first run source ~/.bash_profile or create a new terminal window for the following to work python -version This will set the global version of Python to 3.10.0, which means that any new terminal sessions you open will use this version of Python by default. Once the installation is complete, you can set the global version of Python to 3.10.0 by running the following: pyenv global 3.10.0 Now that you have pyenv configured, you can use it to install Python 3.10: pyenv install 3.10.0 HUMAN NOTE: The `eval “$(pyenv virtualenv-init -)”` will be used later

HUMAN NOTE: If you are using zsh shell (default for macOS Catalina and/or Big Sur) you have to use ~/.zprofile file rather than ~/.bash_profile from StackOverflow export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"

For example, if you’re using Bash, you can add the following to your. Depending on your shell, the file you need to modify may be different.

Run the following: brew install pyenvĪfter installing pyenv, you need to add it to your shell’s configuration file. Next, you can use Homebrew to install pyenv. If you don’t already have it installed, you can install it by running the following command in your terminal: /bin/bash -c "$(curl -fsSL )" First, you’ll need to make sure you have Homebrew installed.
