Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3434118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:39:32+00:00 2026-05-18T07:39:32+00:00

I have MYSQL & MYSQLdb installed with Python 2.6 & Django 1.2.3. I can

  • 0

I have MYSQL & MYSQLdb installed with Python 2.6 & Django 1.2.3. I can open & log on to mysql no problem but it’s not interfacing with python when I check to see if it’s working properly in the python interpreter. This is the error msg I am getting when I invoke it in the 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:39:33+00:00Added an answer on May 18, 2026 at 7:39 am

    Looks like you are using a MacPorts Python installation on MacOS X. If you use MacPorts properly to upgrade, you should not run into problems like that. First, make sure your installation is up-to-date:

    $ sudo port selfupdate
    $ sudo port outdated   # lists outdated ports
    $ sudo port -u upgrade outdated  # upgrade outdated ports and remove old versions
    

    Then, if you still have problems, make sure you don’t have a file permission problem somewhere. It should look something like 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 you don’t have an 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 with 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  # this shows which MySQL client lib the Python DB adapter is dynamically linked to
    _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 with 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 you are really using the 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: the sets module is deprecated
      from sets import ImmutableSet
    /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/_mysql.so
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL database behind a firewall which can only be accessed via
I have a MySQL instance running locally on port 3306, but for some legacy
Now I have my website built on PHP & Mysql. Consider this like a
Anyone knows how to get sum of number? For example i have mysql column
I have a MySQL query that returns a result with a single column of
I have a MySQL table with approximately 3000 rows per user. One of the
I have a MySQL database table with a couple thousand rows. The table is
I have a MySQL database of keywords that are presently mixed-case. However, I want
I have two mysql tables, one containing details on cars and one containing all
I have a mysql database which has grown to over 200 tables in it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.