3

I am trying to setup the environment in Ubuntu (making a shift from MS-Windows). It has, of course, Python 2.6. I did setup MySQL 5512 and MySQLdb from 'Ubuntu Software Centre'.

    import dabo
    import MySQLdb

works OK. No error.

But while establishing a connection, is says that there is a mismatch in versions of MySQLdb & _mysql.

    ImportError: this is MySQLdb version (1, 2, 3, 'gamma', 1), but _mysql
    is version (1, 2, 2, 'final', 0)

How do I solve this?

Complete traceback ---->

   Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "dabovmd/hotel.py", line 4, in <module>
   empconn = dabo.db.dConnection(empci)
   File "dabo/db/dConnection.py", line 32, in __init__
   self._connection = self._openConnection(**kwargs)
   File "dabo/db/dConnection.py", line 80, in _openConnection
   return
   self._connectInfo.getConnection(forceCreate=self._forceCreate, **kwargs)
   File "dabo/db/dConnectInfo.py", line 105, in getConnection
   return self._backendObject.getConnection(self, **kwargs)
   File "dabo/db/dbMySQL.py", line 25, in getConnection
   import MySQLdb as dbapi
   File "/media/pyth/python26/Lib/site-packages/MySQLdb/__init__.py",
   line 23, in <module>
   (version_info, _mysql.version_info))
   ImportError: this is MySQLdb version (1, 2, 3, 'gamma', 1), but _mysql
   is version (1, 2, 2, 'final', 0)

Thanks in advance,

Vineet

1
  • After uninstalling from the 'Ubuntu Software Centre', I tried with separately installing MySQL-python 1.2.2 and 1.2.3.It throws an error locating 'mysql_config' file. Actually that file is present along with setup.cfg How do I solve this? Commented Oct 24, 2011 at 15:55

4 Answers 4

1

This seems like a version mismatch between your MySQL-server and your python-mysqldb.

Which version of Ubuntu are you using? (If you have recently shifted over, then try using Ubuntu 11.04).

The easiest way to solve your problem would be to update your ubuntu to atleast 11.04 and then to install matching versions of mysql-server and python-mysqldb.

I am using Ubuntu 11.04 and my mysql-server version is 5.1.54-1ubuntu4 and my python-mysqldb version is 1.2.2-10build2.

Hope this helps

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for reply Unni. I will try to upgrade Ubuntu, MySQL, MySQLdb. I think it might take a lot of time for upgdating. I will post back the result here.
1

This may not be suitable for your needs, but I've found MySQL Connector/Python to be much much easier to set up than MySQLdb. It's implemented entirely in Python, so it doesn't care about the C interface libraries.

This solution has a couple of downsides. It's supposed to be slower. And more importantly in your case, I know nothing about Dabo so I have no idea if it's possible to sub in a different MySQL interface.

1 Comment

@ mtrw, thanks for the answer. In DABO, MySQLdb is mandatory. BTW, for database oriented apps, DABO is an EXCELLENT package in Python. Either you can use it full (desktop framework) or the 'bizobj' library along with other framework of your choice. See dabodev.com
1

It seems that each of apt-get and pip installed their own version of the library. Try removing system mysql with sudo apt-get remove python-mysqldb, and you should have something like this:

Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: python-mysqldb 0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded. After this operation, 196 kB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 109333 files and directories currently installed.) Removing python-mysqldb (1.2.3-2ubuntu1) ...

Comments

0

Please don't do what has been suggested above...

use these commands in your MySQLdb folder:

sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
sudo python setup.py install

1 Comment

I would be helpful to clarify what was suggested above and why not to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.