38
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python複数version環境をPythonz, virtualenvで管理

Posted at

バージョン管理をPythonz, 仮想環境をvirtualenvで構築

virtualenv, wrapper環境設定

install

$ sudo pip install virtualenv virtualenvwrapper

.zshrcにvirtualenv設定

virtualenv環境を ~/.virtualenvs とする場合

## virtualenv, virtualenvwrapper
which virtualenvwrapper.sh > /dev/null
if [ $? -eq 0 ]; then
    source `which virtualenvwrapper.sh`
    mkdir -p ~/.virtualenvs
    export WORKON_HOME=~/.virtualenvs
    export PIP_RESPECT_VIRTUALENV=true
fi

Pythonz環境設定

install

$ curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash

.zshrcにPythonz設定

# Pythonz
if [ -s $HOME/.pythonz/etc/bashrc ]; then
    source $HOME/.pythonz/etc/bashrc
fi

複数Python version install

$ pythonz install 2.7.5
$ pythonz install 2.6.9
$ pythonz install 3.3.3

# 確認
$ pythonz list

==>
  CPython-2.6.9
  CPython-2.7.5
  CPython-3.3.3

Pythonz + virtualenv

仮想環境作成

$ mkvirtualenv -p ~/.pythonz/pythons/CPython-2.6.9/bin/python2.6 v2.6.9 && deactivate

$ mkvirtualenv -p ~/.pythonz/pythons/CPython-2.7.5/bin/python2.7 v2.7.5 && deactivate

$ mkvirtualenv -p ~/.pythonz/pythons/CPython-3.3.3/bin/python3.3 v3.3.3 && deactivate

環境切り替え & 削除

# activate
$ workon v2.7.5

# deactivate (to System)
$ deactivate

# remove
$ rmvirtualenv v2.6.9

[参考]
・virtualenvwrapper コマンドリファレンス
http://virtualenvwrapper-docs-ja.readthedocs.org/en/latest/command_ref.html

38
37
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
38
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?