fc2ブログ

2013-01-27(Sun)

pythonbrewへpython3.3をインストール

pythonbrewのインストールはこの前ここに記載したので参考にしてもらいたい。

今回はpython3.3を追加した。
追加方法は以下のconfigファイルにpython3.3のパスを追加することで解決。
$HOME/.pythonbrew/etc/config.cfg
以下のスクリプトを作ってみた。
configファイルに追加する記述

$ vim py330.ini
[Python-3.3.0]
url = http://www.python.org/ftp/python/3.3.0/Python-3.3.0.tgz
latest = True


インストールスクリプト

$ vim py330.sh
#!/bin/sh
source $HOME/.pythonbrew/etc/bashrc
cat py330.ini >> ~/.pythonbrew/etc/config.cfg
echo 'python3.3.0'
pythonbrew install 3.3.0


切り替えてみる

$ pythonbrew switch 3.3.0
Switched to Python-3.3.0

できている!


2013-01-13(Sun)

pip install psycopg2でpg_config executable not found

pipでpsycopg2をインストールしたら以下のエラーが発生した。
python2.7.3だ。

(エラー内容)

$ pip install psycopg2
Downloading/unpacking psycopg2
Running setup.py egg_info for package psycopg2

Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:

python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info


エラー内容を読んでみるとpg_configの場所がわからないっぽい。
しかし、pip installで--pg-configパラメータはつけれないのでpipでダウンロードしている
テンポラリー(/tmp/pip-build/psycopg)まで移動してsetup.cfg内にpg_configのパラメータを追加する。

(対応)

$ vim /tmp/pip-build/psycopg2/setup.cfg
pg-config=/usr/local/pgsql/bin/pg_config <- 追加
$ python setup.py install


これで無事インストールできた。

(確認)
pip install psycopg2
Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /home/iida/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages
Cleaning up...

ちゃんとpipに登録されてるっぽい。

2013-01-12(Sat)

DjangoでPython Imaging Library

Djangoで以下のようなエラーが発生したのでメモっておく。

(エラー内容)

$ python manage.py runserver
---
Traceback (most recent call last):
File "/home/iida/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/home/iida/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/django/core/management/base.py", line 270, in validate
raise CommandError("One or more models did not validate:\n%s" % error_text)
django.core.management.base.CommandError: One or more models did not validate:
message.imagemodel: "body": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .
---


エラー内容を読んだらそのままですね。
PILをインストールせよと。

(対応)

$ sudo yum -y install libjpeg-devel
$ sudo yum -y install zlib-devel
$ sudo yum -y install freetype-devel
$ sudo yum -y install python-imaging
$ pip install PIL


pipだけsudoをつけてないのはpythonbrewをローカルアカウントでインストールしているから。



2012-11-04(Sun)

python3.2.3でmysql-connectorをインストール

python2まではmysql-pythonを使っていたが
python3ではインストールでエラー続出なので
使い方がほとんど変わらないmysql-connectorに変更する。

$ pip install mysql-connector-python
Downloading/unpacking mysql-connector-python
Downloading mysql-connector-python-1.0.6b2.zip (492kB): 492kB downloaded
Running setup.py egg_info for package mysql-connector-python

Installing collected packages: mysql-connector-python
Running setup.py install for mysql-connector-python

Successfully installed mysql-connector-python



参考:
Python3 and MySQL connection modules, installation problems

2012-10-29(Mon)

pythonbrew上のpython3.2.3へpipのインストール

pythonbrewをユーザーアカウントへインストールしpython3.2.3へ切り替え
pipをインストールしてみた。

まずはsetuptoolsのインストールだが
$ easy_install
easy_install
....
[Errno 13] Permission denied: '/usr/local/python2.7.3/lib/python2.7/site-packages/test-easy-install-9460.write-test'
....
/usr/local/python2.7.3/lib/python2.7/site-packages/
とpython2.7.3のままだ。

なので直接siete-packagesへ行ってコマンドをたたく。
また、setuptoolsはpython3よりdistributeという名前になっている。

以下のスクリプトを実行
#!/bin/sh
pythonbrew switch 3.2.3
# PYTHON変数を設定
export PYTHON_HOME=/home/hoge/.pythonbrew/pythons/Python-3.2.3/lib/python3.2/site-packages
export PYTHONPATH=/home/hoge/.pythonbrew/pythons/Python-3.2.3

# distribute_setup.pyをダウンロード
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
cd /home/hoge/.pythonbrew/pythons/Python-3.2.3/lib/python3.2/site-packages/distribute-0.6.30-py3.2.egg

# pipをインストール
python easy_install.py pip

Version確認

$ pip --version
pip 1.2.1 from /home/hoge/.pythonbrew/pythons/Python-3.2.3/lib/python3.2/site-packages/pip-1.2.1-py3.2.egg (python 3.2)
ちゃんとpython3.2.3上で実行されていることが確認できる。


参考:
Will setuptools work with python 3.2.x
プロフィール

kumagonjp2

Author:kumagonjp2
Python,Django,R,Mongo,MySQL,Struts,Spring,データマイニングなどサーバー関係のメモを残していきます。

最新記事
最新コメント
最新トラックバック
月別アーカイブ
カテゴリ
雪が3Dで降るブログパーツ ver2

マウスで見る方向変えられます

検索フォーム
RSSリンクの表示
リンク
ブロとも申請フォーム

この人とブロともになる

QRコード
QR