LoginSignup
5
6

More than 3 years have passed since last update.

pyenvでPythonのバージョン管理

Last updated at Posted at 2018-10-06

Python で開発したいけど、ローカル環境を汚したくないので、バージョン管理ツールをつかって Python を入れようと思います。

今回は pyenv を使って導入します。

https://github.com/pyenv/pyenv

環境

  • macOS 10.14.6
  • zsh 5.3 (x86_64-apple-darwin18.0)

Homebrew インストール

公式サイト https://brew.sh/index_ja からインストール

pyenv インストール

# Homebrew でインストール
$ brew install pyenv

インストール後に ~/.zshrc に追記が必要。

.zshrc
...
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
...

追記後、おまじないコマンド

$ source ~/.zshrc

python インストール

# v3.6.5 インストール
$ pyenv install 3.6.5

# 使用する python の設定
$ pyenv global 3.6.5

# 開発リポジトリ以下の python を指定する場合
$ cd /path/to/repository
$ pyenv local 3.6.5

これで、python の設定はおしまい。

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6