LoginSignup
34
36

More than 5 years have passed since last update.

MacのHomebrewでpyenv-virtualenv環境を作る

Last updated at Posted at 2015-06-06

Homebrewでpyenv-virtualenv環境を作る

Homebrewでpyenv-virtualenvインストール

$ brew update
# pyenv-virtualenvインストール(pyenv含まれてます)
$ brew install pyenv-virtualenv
~/.bashrc
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
export PYENV_ROOT=/usr/local/var/pyenv
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi

SHELL更新

$ source ~/.bashrc

python2.7.9バージョンの仮想環境作成

$ pyenv install 2.7.9

仮想環境バージョン一覧確認

$ pyenv versions
> *system
> 2.7.9

python2.7.9バージョンのtest仮想環境作成

$ pyenv virtualenv 2.7.9 test

仮想環境バージョン一覧確認

$ pyenv versions
> *system
> 2.7.9
> test

プロジェクトフォルダ作成

$ mkdir -p ~/project/test
$ cd ~/project/test

このフォルダ配下はtestにする(.python-version が作成される)

$ pyenv local test
$ pyenv versions
> system
> 2.7.9
> *test

仮想環境になっているかどうか確認

(test)$ python --version
Python 2.7.9
(test)$ which python
/usr/local/var/pyenv/versions/test/bin/python
(test)$ pyenv versions
  system
  2.7.9
* test (set by /Users/jjongs08/project/test/.python-version)

環境削除

$ pyenv uninstall test
$ pyenv versions
> *system
> 2.7.9
34
36
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
34
36