开发者

Python MySQL and Django problem

开发者 https://www.devze.com 2023-01-10 11:45 出处:网络
I am having problems getting python/django to connect to a MySQL database. The error message is basically \"Error Loading MySQLDb module: No module named MySQLDb\".

I am having problems getting python/django to connect to a MySQL database. The error message is basically "Error Loading MySQLDb module: No module named MySQLDb".

This is a fresh install right off python.org, so I assumed that it would have the MySQLDb 开发者_JAVA百科module included, but it does not seem to. I also can't seem to find the module or how to install it, except in some sleazy looking parts of the net.

Is there a central point for getting this module? Why isn't it in the standard install? Can someone point me to a tutorial or some such to get this module installed?

Newbie in python, MySQL and Django.

Thanks for help.


I believe http://pypi.python.org/pypi/MySQL-python/ is the Python module you need. In general, when looking for Python modules, http://pypi.python.org/ is where you should start (people will refer to it as either PyPI or "the cheese shop." If setuptools is installed (it may be already) then you can run easy_install MySQL-python.

As far as MySQL is concerned, you'll need to install that separately from a likely-looking package on http://dev.mysql.com/downloads/mysql/.


this is how i handled the issue on Fedora13:

you can get the module here: http://sourceforge.net/projects/mysql-python/

download to a convenient directory

read the README file

build the module, according to the instructions in the README, keeping in mind to use the version of python you are planning to use as an interpreter (2.6 for me). if there are more than one version of python, simply using 'python' will probably alias you into a particular version, which might not be the one you want.

after the build is complete, the .egg file will have been created and landed in a 'site-packages' directory associated with the version of python which was used for the build.

then, ensure that the .egg file created (you can see the install path in the output from the install) is placed on your PYTHONPATH

that did it for me, anyhoo...

good luck! JR

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号