1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Rep Power

    Python doesn't detect MySQLdb


    I have installed the MySQLdb package on my computer according to an article on DevShed. I unpacked it, but my problem is that I don't know where I have to put this folder in order for the Python program to detect it. Should I change any PATH variables somewhere?
    For now when I type "import MySQLdb" in Python Shell, it says there is no module by this name.
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Meriden, Connecticut
    Rep Power
    I'm not even sure if this will make a difference, but try doing:
    from distutils.core import MySQLdb
    This would mean that MySQLdb has to be in the same folder as MySQLdb.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Rep Power
    If it's the MySqlDB package from Sourceforge, the ReadMe file has installation instructions.

    I've never used it, but it looks like you need to configure it a bit first (which version of MySQL are you using, where is it installed, etc), then run the setup.py program to build it, then again to install it...

    Building and installing

    First thing to do is read setup.py. There are some variables towards
    the beginning that tell it where your MySQL include files and
    libraries are, compiler flags, loader flags, etc. You will rarely
    have to change this unless you have some kind of weird setup.

    After the main variables section, there is some platform-specific


    There are several active versions of MySQL out there, and this
    makes it a little tricky to configure setup.py automatically and
    still be cross-platform. setup.py assumes you are using version
    3.23.32. To specify a different version, set the environment
    variable mysqlversion.


    Finally, putting it together:

    $ tar xfz MySQL-python-1.0.0.tar.gz
    $ cd MySQL-python-1.0.0
    $ export mysqlversion="4.0.20"
    $ export mysqlclient="mysqlclient_r"
    $ export mysqloptlibs="ssl crypto"
    $ python setup.py build
    $ su
    # python setup.py install

    NOTE: You must export environment variables for setup.py to see
    them. Depending on what shell you prefer, you may need to use
    "export" or "set -x" (bash and other Bourne-like shells) or "setenv"
    (csh-like shells).

IMN logo majestic logo threadwatch logo seochat tools logo