インストール
1.peyenvのインストール
brew install pyenv-virtualenv
Updating Homebrew…
==> Downloading https://github.com/pyenv/pyenv-virtualenv/archive/v1.1.5.tar.gz
==> Downloading from https://codeload.github.com/pyenv/pyenv-virtualenv/tar.gz/v1.1.5
==> ./install.sh
==> Caveats
To enable auto-activation add to your profile:
if which pyenv-virtualenv-init > /dev/null; then eval “$(pyenv virtualenv-init -)”; fi
==> Summary
🍺 /usr/local/Cellar/pyenv-virtualenv/1.1.5: 22 files, 65.7KB, built in 4 seconds
2.環境変数の設定
$ echo ‘export PYENV_ROOT=”$HOME/.pyenv”‘ >> ~/.bashrc
$ echo ‘export PATH=”$PYENV_ROOT/bin:$PATH”‘ >> ~/.bashrc
$ echo ‘eval “$(pyenv init -)”‘ >> ~/.bashrc
$ source ~/.bashr
3.pyenv-virtualenvのインストール
$ brew install pyenv-virtualenv
Updating Homebrew…
==> Downloading https://github.com/pyenv/pyenv-virtualenv/archive/v1.1.5.tar.gz
==> Downloading from https://codeload.github.com/pyenv/pyenv-virtualenv/tar.gz/v1.1.5
==> ./install.sh
==> Caveats
To enable auto-activation add to your profile:
if which pyenv-virtualenv-init > /dev/null; then eval “$(pyenv virtualenv-init -)”; fi
==> Summary
🍺 /usr/local/Cellar/pyenv-virtualenv/1.1.5: 22 files, 65.7KB, built in 4 seconds
4.環境変数の設定
$ echo ‘eval “$(pyenv virtualenv-init -)”‘ >> ~/.bashrc
$ echo export PYENV_VIRTUALENV_DISABLE_PROMPT=1 >> ~/.bashrc
$ source ~/.bashrc
5.必要なpythonのバージョンをインストール
$ pyenv install 3.8.5
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.5.tar.xz…
-> https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
Installing Python-3.8.5…
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8.5 to /Users/user/.pyenv/versions/3.8.5
環境切替
$ pyenv global 3.8.5
$ python
Python 3.8.5 (default, Sep 5 2020, 18:15:22)
$pyenv global 3.5.5
$ python
Python 3.5.5 (default, Sep 5 2020, 18:19:56)
コメント