"Error Loading Mysqldb Module" When Installing Custom App

I am installing a custom app that needs MySQL, which I already had working so I am a bit confused on what's going on.

Anyways here is the error:

Error loading MySQLdb module: this is MySQLdb version (1, 2, 4, 'final', 1),
  but _mysql is version (1, 2, 3, 'final', 0

Tried

sudo pip uninstall MySQL-python

then

sudo pip install MySQL-python

which worked...

Successfully installed MySQL-python

still the same error

Error loading MySQLdb module: this is MySQLdb version (1, 2, 4, 'final', 1), 
  but _mysql is version (1, 2, 3, 'final', 0
6

1 Answer

It seems that apt-get and pip each 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) ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest