This article describes how to do python on virtual space on macOS.
Preparation: Install Homebrew
First, use Homebrew to install pyenv and pyenv-virtualenv. Enter the following command in the terminal.
$brew install pyenv
$brew install pyenv-virtualenv
We were able to introduce a tool for handling virtual environments.
Then add the following code to your .bash_profile.
python
export PYENV_ROOT=${HOME}/.pyenv
if [ -d "${PYENV_ROOT}" ]; then
export PATH=${PYENV_ROOT}/bin:$PATH
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
Read this.
$ source ~/.bash_profile
Install your favorite Python version in pyenv.
$ pyenv install 3.x.y
Next, specify the Python version that exists in pyenv and build a virtual environment.
$ pyenv virtualenv 3.x.y test
Specify the test environment on your favorite directory.
$ pyenv local test
Now you can run the Python specified in the test environment automatically to that directory.
Recommended Posts