Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18679 > unrolled thread

Error Importing MySQLdb

Started byDavid George <dgeorge@daviddgeorge.com>
First post2012-01-08 16:37 -0500
Last post2012-01-08 21:47 -0800
Articles 7 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  Error Importing MySQLdb David George <dgeorge@daviddgeorge.com> - 2012-01-08 16:37 -0500
    Re: Error Importing MySQLdb Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-01-08 17:17 -0500
      Re: Error Importing MySQLdb davidfx <dgeorge29ca@gmail.com> - 2012-01-08 14:37 -0800
      Re: Error Importing MySQLdb davidfx <dgeorge29ca@gmail.com> - 2012-01-08 14:37 -0800
        Re: Error Importing MySQLdb Dave Angel <d@davea.name> - 2012-01-08 18:08 -0500
        Re: Error Importing MySQLdb Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-01-08 20:23 -0500
          Re: Error Importing MySQLdb John Nagle <nagle@animats.com> - 2012-01-08 21:47 -0800

#18679 — Error Importing MySQLdb

FromDavid George <dgeorge@daviddgeorge.com>
Date2012-01-08 16:37 -0500
SubjectError Importing MySQLdb
Message-ID<L0oOq.65165$8O1.34287@newsfe07.iad>
Hello there,
I have been trying for awhile now to get MySQLdb working. I am currently 
getting this error when trying to import it:

 >>> import MySQLdb

Traceback (most recent call last): File "", line 1, in File 
"build/bdist.macosx-10.7-intel/egg/MySQLdb/init.py", line 19, in File 
"build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in File 
"build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in bootstrap 
ImportError: 
dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 
2): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib 
Referenced from: 
/Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so 
Reason: image not found

Anyone know what I need to do in order to correct these errors.

Thanks

[toc] | [next] | [standalone]


#18682

FromBenjamin Kaplan <benjamin.kaplan@case.edu>
Date2012-01-08 17:17 -0500
Message-ID<mailman.4532.1326061044.27778.python-list@python.org>
In reply to#18679
On Sun, Jan 8, 2012 at 4:37 PM, David George <dgeorge@daviddgeorge.com> wrote:
> Hello there,
> I have been trying for awhile now to get MySQLdb working. I am currently
> getting this error when trying to import it:
>
>>>> import MySQLdb
>
> Traceback (most recent call last): File "", line 1, in File
> "build/bdist.macosx-10.7-intel/egg/MySQLdb/init.py", line 19, in File
> "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in File
> "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in bootstrap
> ImportError:
> dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so,
> 2): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib Referenced
> from:
> /Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
> Reason: image not found
>
> Anyone know what I need to do in order to correct these errors.
>
> Thanks

MySQLdb is having trouble loading the MySQL client library. Since I
assume MySQL is installed, my best guess is that you have an
architecture problem. Your Python is probably running in 64-bit mode.
Do you have a 64-bit MySQL install? The "file" command will tell you
which architectures are in a binary if you're unsure.

[toc] | [prev] | [next] | [standalone]


#18683

Fromdavidfx <dgeorge29ca@gmail.com>
Date2012-01-08 14:37 -0800
Message-ID<mailman.4533.1326062232.27778.python-list@python.org>
In reply to#18682
I am not sure what file you mean.  Where should I look for the file you are talking about?  By the way MySQL works fine within MAMP.

Thanks for your suggestions.

[toc] | [prev] | [next] | [standalone]


#18684

Fromdavidfx <dgeorge29ca@gmail.com>
Date2012-01-08 14:37 -0800
Message-ID<18369429.1936.1326062224503.JavaMail.geo-discussion-forums@vbdz6>
In reply to#18682
I am not sure what file you mean.  Where should I look for the file you are talking about?  By the way MySQL works fine within MAMP.

Thanks for your suggestions.

[toc] | [prev] | [next] | [standalone]


#18685

FromDave Angel <d@davea.name>
Date2012-01-08 18:08 -0500
Message-ID<mailman.4534.1326064115.27778.python-list@python.org>
In reply to#18684
On 01/08/2012 05:37 PM, davidfx wrote:
> I am not sure what file you mean.  Where should I look for the file you are talking about?  By the way MySQL works fine within MAMP.
>
> Thanks for your suggestions.
In most Linux/Unix systems, there is a file utility on the system PATH.

To find the type of a particular file, you run it as
     file    unknowndata

and it'll use its heuristics to guess what kind of data you have, 
written by what software, or what type of executable you have, and 
whether it's 32 bit or 64, etc.



-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#18690

FromBenjamin Kaplan <benjamin.kaplan@case.edu>
Date2012-01-08 20:23 -0500
Message-ID<mailman.4537.1326072193.27778.python-list@python.org>
In reply to#18684
On Sun, Jan 8, 2012 at 5:37 PM, davidfx <dgeorge29ca@gmail.com> wrote:
> I am not sure what file you mean.  Where should I look for the file you are talking about?  By the way MySQL works fine within MAMP.
>
> Thanks for your suggestions.


Like I said, it's likely an architecture issue. If you have a 32-bit
MySQL install and are using a 64-bit Python, it won't be able to load
the client libraries. The Python install included in Lion is universal
(a single file containing both 32-bit and 64-bit executables) so if
it's loaded by a 32-bit program, it will load in 32-bit mode.

"file" is a command that uses heuristics to determine the type of a
file. You run it from a terminal.

$ file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 2 architectures
/usr/bin/python (for architecture x86_64):	Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture i386):	Mach-O executable i386

Try running "file /usr/local/lib/libmysqlclient.18.dylib". According
to the traceback you posted, that's the library that failed to load.

If you need to force Python to run in 32-bit mode, you can use the arch command
"arch -i386 python"

[toc] | [prev] | [next] | [standalone]


#18700

FromJohn Nagle <nagle@animats.com>
Date2012-01-08 21:47 -0800
Message-ID<4f0a7f54$0$1659$742ec2ed@news.sonic.net>
In reply to#18690
On 1/8/2012 5:23 PM, Benjamin Kaplan wrote:
> On Sun, Jan 8, 2012 at 5:37 PM, davidfx<dgeorge29ca@gmail.com>  wrote:
>> I am not sure what file you mean.  Where should I look for the file you are talking about?  By the way MySQL works fine within MAMP.
>>
>> Thanks for your suggestions.
>
>
> Like I said, it's likely an architecture issue. If you have a 32-bit
> MySQL install and are using a 64-bit Python, it won't be able to load
> the client libraries. The Python install included in Lion is universal
> (a single file containing both 32-bit and 64-bit executables) so if
> it's loaded by a 32-bit program, it will load in 32-bit mode.

     Actually, the issue is only whether you have 64-bit MySQL client 
libraries for C to which MySQLdb can link.  Those are called
"MySQL Connector/C", and here are the download pages for them.

http://dev.mysql.com/downloads/connector/c/

The actual database can (and usually should be) the 64-bit executable, 
while the libraries can be 32 or 64 bit. They communicate over a socket,
and don't even need to be on the same machine.

Unfortunately, the whole MySQLdb/Python/Connector/C versioning
setup is a mess.  See:

	http://chaos.weblogs.us/archives/327

				John Nagle

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web