root権限がなく、個人のディレクトリにPythonをインストールしたいとき
- Pythonをダウンロード→http://python.org/getit/
- ダウンロードしたディレクトリまで移動
- tar zxfv Python-2.7.2.tgz
- cd Python-2.7.2
- ./configure --prefix=$HOME/◯◯←インストールしたいディレクトリ
- make
- make install
- 環境変数を設定(ホームディレクトリの.bashrcに以下を追加)
- if [ $SHLVL=1 ]; then
- export PYTHONHOME=$HOME/◯◯
- export PATH=$HOME/◯◯/bin:$PATH
- fi
Eclipse + PyDev
- プロキシ経由でPyDevのインストールを行うには、ウインドウ→設定からプロキシの設定が必要
日本語を扱うときの注意
- UnicodeEncodeError: 'ascii' codec can't encode characters in position ◯-◯: ordinal not in range(128) の対処法
out = file('ABC.txt','w') for word in wordlist: out.write('\t%s' % word) ← ここにエラー ↓ import codecs ← これを追加 out = file('ABC.txt','w') out = codecs.lookup('utf_8')[-1](out) ← これを追加 for word in wordlist: out.write('\t%s' % word) ← エラーなし! 参考:PythonのUnicodeEncodeErrorを知る
|