34
28

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.

Virtualenvの使い方

Last updated at Posted at 2015-08-15

2通りの方法を記述します。

  • virtualenvのみ利用(「Only virtualenv」)
  • virtualwrapper も利用(「With virtualenvwrapper」)

表記上の注意

# : rootで実行。
$ : 一般ユーザ(root以外)で実行。

仮想環境の構築

Only virtualenv

カレントディレクトリに構築します。

$ virtualenv --python=/usr/local/bin/python project-env

With virtualenvwrapper

Python3.4 インストールで設定した$WORKON_HOMEの配下に構築します。

$ mkvirtualenv --python=/usr/local/bin/python project-env

仮想環境の活性化(activate)

仮想環境を利用する前に実行します。

Only virtualenv

$ cd /var/www/python
$ source ./project-env/bin/activate

With virtualenvwrapper

$ workon project-env

ホームディレクトリ配下の仮想環境project-envが活性化します。

仮想環境の不活性化(deactivate)

仮想環境から抜けるときに実行します。

Only virtualenv & With virtualenvwrapper

$ deactivate
34
28
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
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?