雪豹10.6.2下安装Django/MySQLdb

春节期间研究了一下Django框架,为今年的互联网应用做些储备

以前有过两年的Python的使用经验,所以上手并不困难,但在实现Django持久化时遇到了一点问题。

Django支持各种数据库,包括postgresql,mysql和oracle,方便起见,用了最常用的开源mysql,这就需要安装MySQLdb。

我的操作系统时雪豹10.6.2,系统默认安装了Python,我又装了Mysql

下载了MySQL-python-1.2.3c1.tar.gz,然后

cd MySQL-python-1.2.3c1
python setup.py build
sudo python setup.py install
一切顺利,执行:
$ python
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
出现错误:
Traceback (most recent call last):
File "", line 1, in 
File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py", line 19, in 
ImportError: dynamic module does not define init function (init_mysql)
Google了一下,发现有可能时Mysql和Python的32位64位的问题
检查了系统,发现Mac OS自带的是64位python我装的Mysql是32位的,问题找到了。
重装了64位的Mysql,删除build下的文件,重新build,install,一切顺利。

posted @ 2011-05-09 22:20  池建强  阅读(1160)  评论(0编辑  收藏  举报