22
21

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.

Pythonzとvirtualenvでクリーンなpython環境

Last updated at Posted at 2013-07-02

環境はUbuntu

必要なパッケージをインストールする

apt-get -y update
apt-get -y upgrade
apt-get -y install python
apt-get -y install python-setuptools
apt-get -y install python-pip
apt-get -y install python-virtualenv

Pythonzのインストール

cd ~
curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash
echo '[[ -s $HOME/.pythonz/etc/bashrc ]] && source $HOME/.pythonz/etc/bashrc' >> ~/.bashrc
source ~/.bashrc

PythonzでPythonをインストール

好きなバージョンインストール出来ます。とりあえず2系の最新をインストール

pythonz install 2.7.5

virtualenvの設定

virtualenv -p ~/.pythonz/pythons/CPython-2.7.5/bin/python ~/.pythonz/virtualenv/Python-2.7.5
echo 'PATH=$HOME/.pythonz/virtualenv/Python-2.7.5/bin:$PATH' >> ~/.profile
source ~/.profile

Pythonの文字コードをUTF-8にしておく

cd ~/.pythonz/virtualenv/Python-2.7.5/lib/python2.7/site-packages
touch sitecustomize.py
echo 'import sys' >> sitecustomize.py
echo 'sys.setdefaultencoding("utf-8")' >> sitecustomize.py
```

Pythonz + virtualenvでglobalなpython環境を汚染せずにバージョン管理、パッケージ管理が出来るようになります。
22
21
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
22
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?