Problem with python + mysql


I’m trying to connect to mysql from a python script. I’m using import _mysql just to try things out.

The problem is that apparently this module is looking for a library but I have installed. Shouldn’t the module take my newer version of the file? Thanks!

Where did you get python-mysql from? I’ve just checked this is working fine here. Just got it from the normal OSS repo.

mmm, I don’t know where I got it from… how can I tell? What version of the lib do you have? 15 or 16? Thanks!

To find out where from

zypper se -s python-mysql
Loading repository data...
Reading installed packages...

S | Name         | Type    | Version    | Arch | Repository
i | python-mysql | package | 1.2.2-87.1 | i586 | openSUSE_11.2-0

I also have

rpm -qf /usr/lib/

By the way I’m presuming 11.2


I have this:

Package from openSUSE-11.2-Oss


rpm -qf /usr/lib/

And yes, I’m on 11.2


Not sure what to say but all I did was install mysql and python-mysql then hit the interpreter with import and connected with a user.

I don’t get the error

Ok. Thanks anyway. I’ll keep looking :slight_smile:

You didn’t check the version and provenance of python-mysql as FeatherMonkey showed you how. You may also have some other python to mysql connector that is expecting an older version of the mysql client library.

I did check, I posted a short version of the output, because my system is in Spanish, but here is the complete output:

E | Nombre | Tipo | Versión | Arquitectura | Repositorio
i | python-mysql | paquete | 1.2.2-87.1 | i586 | openSUSE-11.2-Oss

Curious does the interpreter work for you?(Not that I really would expect a difference)

You might have another older Python module that’s getting loaded and handling mysql. Do you have other Python libraries installed? They might be interfering.

The interpreter is working just fine. The library I recently installed is Django. Other than that I don’t think I have anything in particular…

The leading question is where did you get django from any way I just checked in case…

This one works fine for me just checked created the tables as the tut fine. Direct link to rpm 1.1.1-7.1 on devel:languages:python/openSUSE_11.2

Well, thank you very much for your help. I have downloaded the rpm file you pointed and installed it, but the problem is still there. I believe there must be an issue with the python-mysql package (or something).
Yesterday I tried installing the python-mysql package in a different computer (which I installed myself) with OpenSuse 11.2 and it worked just fine, so I guess there must be a conflicting python lib here, but I can’t tell which one is.
I usually develop php and I use xampp, could this be a problem?

Bit out of my depth here but you had me intrigued. If Ken or someone else doesn’t come up with a better idea perhaps showing the python modules installed will help you find the answer.

On the python:devel repo you have python-yolk after installing a yolk -l seems to list modules installed.

Ok. I installed yolk. Here’s the output from yolk -l:

BeautifulSoup   - 3.0.7a       - active 
Coherence       - 0.6.4        - active 
Django          - 1.1.1        - non-active 
Django          - 1.1.1        - non-active 
Django          - 1.1.1        - active development (/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg)
Django          - 1.1.1        - active development (/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg)
MySQL-python    - 1.2.2        - non-active 
MySQL-python    - 1.2.3c1      - active development (/usr/local/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg)
PyGreSQL        - 3.8.1        - active 
PyMySQL         - 0.2          - active development (/usr/local/lib/python2.6/site-packages/PyMySQL-0.2-py2.6.egg)
PyOpenGL        - 3.0.0        - active 
PyPAM           - 0.5.0        - active 
PyXML           - 0.8.4        - active 
PyYAML          - 3.09         - active 
Python          - 2.6.2        - active development (/usr/lib/python2.6/lib-dynload)
Twisted         - 8.2.0        - active 
ccsm            - 0.7.8        - active 
cups            - 1.0          - active 
cupshelpers     - 1.0          - active 
docutils        - 0.5          - active 
elementtree     - 1.2.6-20050316 - active development (/usr/local/lib/python2.6/site-packages)
gdata           - 2.0.1        - active 
httplib2        - 0.5.0        - active 
louis           - 1.7.0        - active 
lxml            - 2.2.2        - active 
networkx        -      - active development (/usr/local/lib/python2.6/site-packages/
numpy           - 1.3.0        - active 
pyOpenSSL       - 0.9          - active 
pyserial        - 2.4          - active 
setuptools      - 0.6c9        - active 
simple-ccsm     - 0.7.8        - active 
simplejson      - 2.0.9        - active 
smbc            - 1.0          - active 
urlgrabber      - 3.1.0        - active 
wsgiref         - 0.1.2        - active development (/usr/lib/python2.6)
yolk            - 0.4.1        - active development (/usr/local/lib/python2.6/site-packages/yolk-0.4.1-py2.6.egg)
zope.interface  - 3.3.0        - active 

Well I’m guessing here but we’ve tracked down the module as to the how or the fix. Maybe you have 2 python-myslq try querying the rpm database or zypper iirc zypper se python-mysql. The other would be to find the generic python way to uninstall not sure on the how though.

The problem… the active one looks like an egg install to me, so the fix I would suspect would be the egg way.

MySQL-python    - 1.2.2        - non-active 
MySQL-python    - 1.2.3c1      - active development (/usr/local/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg)

From here the active is the normal packages on sys.path you can import Yolk - Trac

I would also suspect

PyMySQL - 0.2 - active development (/usr/local/lib/python2.6/site-packages/PyMySQL-0.2-py2.6.egg)


Well, I think I finnally solved my problem. I removed the file /usr/local/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg and now I can import the module _mysql without any problem.

My issue now is setting the appropriate unix socket to connect to mysql, but that already happened to me when trying to connect to my localhost from a gui client, so I guess I can take it from here. Thank you all very much. Hope my experience will help someone in the future.