LoginSignup
5
5

More than 5 years have passed since last update.

Mac(Mountain Lion)にPython環境を構築

Posted at

Pythonのインストールにpythonzを使っている記事が多かったが、ここを参考に、Pythonのインストールはhomebrewで行う。

Pythonのインストール

# 2系のpythonをインストール
% brew install python

# 3系のpythonをインストール
% brew install python3

virtualenvとvirtualenvwrapperのインストール

virtualenvとvirtualenvwrappeについてはこの辺を参照。

% pip install virtualenv virtualenvwrapper

virtualenvとvirtualenvwrapperの設定

.zshrcに以下を追記

# virtualenvwrapperが使うpythonを指定
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
# pipをグローバルにインストールした場合でも, virtualenv環境にパッケージをインストールする.
export PIP_RESPECT_VIRTUALENV=true
source "/usr/local/bin/virtualenvwrapper.sh"

仮想環境の作成

# python2系を使用するpy2という環境を作成
% mkvirtualenv py2 --python /usr/local/bin/python2

# python3系を使用するpy3という環境を作成
% mkvirtualenv py3 --python /usr/local/bin/python3

# 作成した仮想環境を確認
% lsvirtualenv
py2
===


py3
===


(py3)

virtualenvwrapperコマンド

virtualenvwrapper 3.5 - コマンドリファレンス

参照

Kesin's diary プログラミングの記事がメインです。Python率高し - 結局Pythonはvirtualenvで管理してみることにした
今日のPython - VIRTUALENV について
kanonjiのブログ - pythonzとvirtualenvとvirtualenvwrapperでPython環境構築のメモ

5
5
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
5