Tutorial :Python MySQL and Django problem



Question:

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 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.


Solution:1

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/.


Solution:2

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


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »