Skip to main content
deleted 33 characters in body; edited tags; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to access mysql Accessing MySQL data from python built-in console of QGIS?

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> https://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

How to access mysql data from python built-in console?

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> https://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

Accessing MySQL data from python built-in console of QGIS?

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

ACKNOWLEDGE:

..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 -> https://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> http://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1https://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> http://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> https://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

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 xxx.py 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?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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> http://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> http://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

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 xxx.py 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/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.8-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/Arthur/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

Thanks for reading!

ACKNOWLEDGE:

..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 -> http://stackoverflow.com/questions/12327737/error-importing-mysqldb-in-python-2-7-2-on-mac-osx-10-8-1

Thanks

Found reason for architecture mismatch, compiling MySQLdb against python 2.7.
Source Link
Loading
code formatting, other minor edits
Source Link
djq
  • 16.3k
  • 31
  • 112
  • 182
Loading
edited title
Link
underdark
  • 84.5k
  • 22
  • 233
  • 415
Loading
added 1004 characters in body
Source Link
Loading
Source Link
Loading