LoginSignup
1
2

More than 3 years have passed since last update.

2017-03-17 CentOS 6.8 > Python 3.6.0をvirutalenvで導入 / 使用開始 / 使用停止

Last updated at Posted at 2017-03-17
動作環境
Xeon E5-2620 v4 (8コア) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 とその-devel
mpich.x86_64 3.1-5.el6とその-devel
gcc version 4.4.7 (とgfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.1を使用。
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) 

Python3環境をvirtualenvで導入してみる。

参考 http://qiita.com/a_yasui/items/5f453297855791ed648d

Python 2系列については未実施。
Python 3.6.0に関して、「Easy_install をインストールさせる」以外の項目を実施。
/opt/localディレクトリはなかったため作成した。

導入後の使い方は以下で実施。

$ cd
$ /opt/local/bin/virtualenv venv_py360

ここでvenv_py360はPython 3.6.0のvirtualenvの意味 (任意の文字列)。

$ source venv_py360/bin/activate

にて使用開始。

$ deactivate 

にて使用停止。

CentOS 6.8にはもともとPython 2.6.6が入っており、deactivateにすればそちらが使える。

これでPython 2とPython 3のいずれでも使えるようにはなりそう。

virtualenvwrapperなどもあるが、必要になってから使うのでいいかと思う。

/opt/local/binにPython 2とPython 3両方入れて問題ないかは未確認。pip install virtualenvをPython 2とPython 3でした時に/opt/local/bin/virtualenvを後者が上書きするのだろうか。

間違って作ったvirtualenv環境はrm -rfで消すようだ (rmvirtualenv コマンドがない環境にて)。
http://stackoverflow.com/questions/11005457/how-do-i-remove-delete-a-virtualenv

Simply remove the virtual environment from the system.There's no special command for it

rm -rf venv

補足事項 > numpyのインストール

numpyなど使うものをインストール。pip installでは失敗 (No module が表示)。
virtualenvをactivateした状態で以下とした。

$ easy_install numpy
(中略)
Adding numpy 1.12.1rc1 to easy-install.pth file
Installing f2py3.6 script to /home/[user]/venv_py360/bin

Installed /home/[user]/venv_py360/lib/python3.6/site-packages/numpy-1.12.1rc1-py3.6-linux-x86_64.egg
Processing dependencies for numpy
Finished processing dependencies for numpy
1
2
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
1
2