During the Spring Festival, I studied the Django framework and made some reserves for this year's Internet applications.
I have been using python for two years before, so it is not difficult to get started, but I encountered a problem in implementing Django persistence.
Django supports a variety of databases, including PostgreSQL, MySQL, and Oracle. For convenience, the most common open source MySQL is used. Therefore, mysqldb needs to be installed.
In my operating system, snow leopard 10.6.2. python is installed by default, and MySQL is installed again.
Download mysql-python-1.2.3c1.tar.gz, and then
CD MySQL-python-1.2.3c1
Python setup. py build
Sudo Python setup. py install
Everything goes smoothly. Execute:
$ Pythonpython 2.6.1 (r261: 67515, Jul 7 2009, 23:51:51) [GCC 4.2.1 (Apple Inc. build 5646)] on darwintype "help", "Copyright", "Credits" or "License" for more information. >>> import mysqldb
Error:
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)
I googled it and found that MySQL and Python may have 32-bit 64-bit problems. I checked the system and found that the Mac OS comes with 64-bit python. I installed MySQL with 32-bit, the problem is found. Reinstall the 64-bit MySQL, delete the files under the build, re-build and install, and everything went smoothly.