LoginSignup
76
68

More than 5 years have passed since last update.

Anaconda3を入れた後,python2.7を使いたくなった時の環境構築法

Last updated at Posted at 2015-12-05

virtualenvを使う必要もなく
$ conda create -n py27 python=2.7 anaconda
とすれば,{Anaconda3のパス}/env/py27 が作成される.

python2.7を使いたくなったら下記コマンド.

windowsでは
$ activate py27

python3に戻すときは下記コマンド.
$ deactivate

以上,非常に簡単. Anaconda素晴らしい.

【追記】 macでは
python2.7を使うときは, (anaconda3-2.5.0の場合)
$ source ~/.pyenv/versions/anaconda3-2.5.0/bin/activate py27
python3に戻すときは
$ source ~/.pyenv/versions/anaconda3-2.5.0/bin/deactivate

上記は長いので, ~/.bashrc などに下記を追記しておくと便利
alias py2='source ~/.pyenv/versions/anaconda3-2.5.0/bin/activate py27'
alias py3='source ~/.pyenv/versions/anaconda3-2.5.0/bin/deactivate'

すると
$ py2

$ py3
でpythonのバージョンの切り替えができる.

参考URL

76
68
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
76
68