fc2ブログ
MySQL-Pythonの設定
なんかいつもMySQL-Pythonで躓いているような気がしますが、またころんだのでメモっておきます。
MacOSX10.6.7でPython2.6として動かしている2.6.4です。

まず、ダウンロード後ビルドしようとすると、
~/MySQL-python-1.2.3$ python2.6 setup.py build
Traceback (most recent call last):
File "setup.py", line 5, in
from setuptools import setup, Extension
ImportError: No module named setuptools
~/MySQL-python-1.2.3$ ez_setup.py
-bash: ez_setup.py: command not found

あら、入ってなかったか。と、思いつつ・・・

~$ sh setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /Library/Frameworks/Python.framework/Versions/2.6/bin
Installing easy_install-2.6 script to /Library/Frameworks/Python.framework/Versions/2.6/bin
Installed /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

ようやく、
~/MySQL-python-1.2.3$ python2.6 setup.py build
running build
running build_py
creating build
creating build/lib.macosx-10.3-fat-2.6
copying _mysql_exceptions.py -> build/lib.macosx-10.3-fat-2.6
「中略・・・」
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.3-fat-2.6/_mysql.o -Os -arch i386 -fno-common
unable to execute gcc-4.0: No such file or directory
error: command 'gcc-4.0' failed with exit status 1

なにー。そんなこと言われたことあるかなー?と思いつつ、
locate gcc-4.0 | grep bin
などとしてみると、/Developer/usr/bin/gcc-4.0にあるらしい。
PATHを通して再度実行。

~/MySQL-python-1.2.3$ python2.6 setup.py build
今度はうまくいったので、すかさず、
sudo python2.6 setup.py install
で、インストール完了。

試してみましょう。
~/MySQL-python-1.2.3$ python2.6
Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg/_mysql.pyc, but /Users/tsuji/MySQL-python-1.2.3 is being added to sys.path

と言われて一瞬焦ったが、これはモジュールをインストールしたディレクトリから慌ててimportしたため。で、一件落着。
スポンサーサイト



テーマ:プログラミング - ジャンル:コンピュータ

【2011/05/22 22:30】 | Python | トラックバック(0) | コメント(0) | page top↑
<<ポアンカレ予想 | ホーム | Webアプリの作り方を学ぶなら、こちらを!>>
コメント
コメントの投稿














管理者にだけ表示を許可する

トラックバック
トラックバックURL
→http://tanopy.blog79.fc2.com/tb.php/73-8ceef852
この記事にトラックバックする(FC2ブログユーザー)
| ホーム |