python mysqldb problem interfacing with python 2.6 & or mysql -
i have mysql & mysqldb installed python 2.6 & django 1.2.3. can open & log on mysql no problem it's not interfacing python when check see if it's working in python interpreter. error msg getting when invoke in interpreter....
import mysqldb traceback (most recent call last): file "<stdin>", line 1, in <module> file "/opt/local/library/frameworks/python.framework/versions/2.6/lib/python2.6/site-packages/mysqldb/__init__.py", line 19, in <module> import _mysql importerror: dlopen(/opt/local/library/frameworks/python.framework/versions/2.6/lib/python2.6/site-packages/_mysql.so, 2): library not loaded: /opt/local/lib/mysql5/mysql/libmysqlclient_r.15.dylib referenced from: /opt/local/library/frameworks/python.framework/versions/2.6/lib/python2.6/site-packages/_mysql.so reason: image not found
looks using macports
python installation on macos x. if use macports
upgrade, should not run problems that. first, make sure installation up-to-date:
$ sudo port selfupdate $ sudo port outdated # lists outdated ports $ sudo port -u upgrade outdated # upgrade outdated ports , remove old versions
then, if still have problems, make sure don't have file permission problem somewhere. should this:
$ ls -l /opt/local/lib/mysql5/mysql total 93824 -rw-r--r-- 2 root admin 1824 nov 22 16:10 libdbug.a -rw-r--r-- 2 root admin 161176 nov 22 16:10 libheap.a -rw-r--r-- 2 root admin 900552 nov 22 16:10 libmyisam.a -rw-r--r-- 2 root admin 136472 nov 22 16:10 libmyisammrg.a -rwxr-xr-x 2 root admin 2871400 nov 22 16:10 libmysqlclient.16.dylib* -rw-r--r-- 2 root admin 3224032 nov 22 16:10 libmysqlclient.a lrwxr-xr-x 1 root admin 23 nov 22 16:10 libmysqlclient.dylib@ -> libmysqlclient.16.dylib -rwxr-xr-x 2 root admin 1028 nov 22 16:10 libmysqlclient.la* -rwxr-xr-x 2 root admin 2891208 nov 22 16:10 libmysqlclient_r.16.dylib* -rw-r--r-- 2 root admin 3248504 nov 22 16:10 libmysqlclient_r.a lrwxr-xr-x 1 root admin 25 nov 22 16:10 libmysqlclient_r.dylib@ -> libmysqlclient_r.16.dylib -rwxr-xr-x 2 root admin 1040 nov 22 16:10 libmysqlclient_r.la* -rw-r--r-- 2 root admin 25939344 nov 22 16:10 libmysqld.a -rw-r--r-- 2 root admin 2643984 nov 22 16:10 libmystrings.a -rw-r--r-- 2 root admin 667720 nov 22 16:10 libmysys.a -rwxr-xr-x 2 root admin 2039856 nov 22 16:10 libndbclient.3.dylib* -rw-r--r-- 2 root admin 3221192 nov 22 16:10 libndbclient.a lrwxr-xr-x 1 root admin 20 nov 22 16:10 libndbclient.dylib@ -> libndbclient.3.dylib -rwxr-xr-x 2 root admin 976 nov 22 16:10 libndbclient.la* -rw-r--r-- 2 root admin 29568 nov 22 16:10 libvio.a drwxr-xr-x 2 root admin 612 nov 22 16:10 plugin/
also make sure don't have architecture mismatch:
$ cd /opt/local/library/frameworks/python.framework/versions/2.6/lib/python2.6/site-packages/ $ file _mysql.so _mysql.so: mach-o universal binary 2 architectures _mysql.so (for architecture x86_64): mach-o 64-bit bundle x86_64 _mysql.so (for architecture i386): mach-o bundle i386 $ otool -l _mysql.so # shows mysql client lib python db adapter dynamically linked _mysql.so: /opt/local/lib/mysql5/mysql/libmysqlclient_r.16.dylib (compatibility version 17.0.0, current version 17.0.0) /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5) /usr/lib/libsystem.b.dylib (compatibility version 1.0.0, current version 125.2.0) /opt/local/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8) /opt/local/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8) $ cd /opt/local/lib/mysql5/mysql/ $ file libmysqlclient_r.16.dylib libmysqlclient_r.16.dylib: mach-o universal binary 2 architectures libmysqlclient_r.16.dylib (for architecture i386): mach-o dynamically linked shared library i386 libmysqlclient_r.16.dylib (for architecture x86_64): mach-o 64-bit dynamically linked shared library x86_64
and, of course, make sure using macports
python:
$ /opt/local/bin/python2.6 -v python 2.6.6 $ /opt/local/bin/python2.6 -c 'import mysqldb; print(mysqldb._mysql.__file__)' /opt/local/library/frameworks/python.framework/versions/2.6/lib/python2.6/site-packages/mysqldb/__init__.py:34: deprecationwarning: sets module deprecated sets import immutableset /opt/local/library/frameworks/python.framework/versions/2.6/lib/python2.6/site-packages/_mysql.so
Comments
Post a Comment