Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm writing a QGIS Plugin, and somewhere I want to present data from a MySQL database. It's simple data(strings,etc), not Geospatial, or vector data. I'm familiar with querying databases from python scripts, and now I want to present data inside a TextBrowser QT Widget inside QGIS.

However, I can't import MySQLdb from built-in console, neither from my file inside my plugin folder. From the Apple Terminal i can import MySQLdb with no problems.

I've read Why can't I import my script from the python console?, but still have no success, because when I call import MySQLdb inside a script that resides on a folder added to sys.path, it still fails.

Calling import MySQLdb from built-in console tells:

import MySQLdb
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/", line 19, in <module>
  File "/Applications/", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/ mach-o, but wrong architecture

Thanks for reading!


..mach-o, but wrong architecture -> this reveals a mismatch between python-mysqldb-mysql architecture!

The problem is that MySQLdb, does not support python2.7, as compiling for x86_64! Even if python and mysql-server are 64bits. Switching to python2.6, MySQLdb compiles a x86_64 binary; but QGIS 1.8 is built against python 2.7, so still does not work. Is it possible to select python framework inside QGIS?

This was very helpful ->


share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.