Unable to load Python bindings for MySQL - Trac

I recently started getting the following error in my trac installation:

Unable to load Python bindings for MySQL

Unfortunately, I had to reinstall MySQL, and then I started getting these problems. I spent the last hour trying to track something on Google, but I couldn't get it to work. I made sure that MySQL is working correctly. I created a new MySQL user specific to trac. I made sure that all the packages are there. Nothing.

Here is my dkpg (I ran Ubuntu Maverick):

dpkg -l | grep python

  • libapache2-python mod
  • libapache2-mod-python-document
  • libpython2.6
  • libpython3.1
  • python
  • python central
  • python-docutils
  • python genshi
  • python images
  • python-lxml
  • python is minimal
  • Python MySQLdb
  • python PKG resources
  • python pybabel
  • python-pygments
  • python romance
  • python setuptools
  • python subversion
  • python support
  • python tz
  • python2.6
  • python2.6 is minimal
  • python3.1
  • python3.1 is minimal

If anyone has any ideas as to what this might be, I will be forever grateful.

+4
source share
2 answers

This error should occur if Trac tries to execute " import MySQLdb ", but it fails. You have the correct package that this module should provide, but for some reason it does not work. To find out why, you should look at the environment in which Trac runs. Is Python used other than /usr/bin/python2.6 ? Does he have a set of $PYTHONPATH ?

You can also try importing MySQLdb directly:

 /usr/bin/python2.6 -c 'import MySQLdb' 

This should not have an exit if the package can be downloaded as expected.

Finally, it may not be related, but you know that Maverick is no longer supported, right? It will not receive security updates or other support from Ubuntu.

Edit:

The python2.6 import worked fine, so we need to look closer to the trac environment. One way to do this is to edit the db/mysql_backend.py and insert some debugging information. (If this is an OS batch installation, you should find this file under /usr/lib/python2.6/dist-packages/trac/ , otherwise you probably know where you put it). Try changing the MySQLConnector.get_supported_schemes() method, as I'm not sure where the regular print will be displayed.

 def get_supported_schemes(self): if not has_mysqldb: import sys self.error = "Cannot load Python bindings for MySQL. sys.path = %r, sys.executable = %r" \ % (sys.path, sys.executable) yield ('mysql', -1 if self.error else 1) 
+1
source

instead of calling a specific python installation, as paul suggests, try this on your terminal:

run python path instance

 python 

see if mysqldb can be imported

 import MySQLdb 

also launched for us:

 pip freeze 

we should see a mysql-python output

0
source

All Articles