473,898 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Huge problem gettng MySQLdb to work on my mac mini running Macosx10.5 Leopard

Hi all,

I have a mac mini running maocosx 10.5 leopard I want to deploy a
django project on. My backend is MySQL, and I have it running as a 64-
bit app. Of course, apache2 is also running as 64-bit.

MySQLdb installs with the usual warnings after applying the various
patches I found here and there. These patches consist of altering
_mysql.c and site.cfg.

Basically, my problem boils down to this:

File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py", line
19, in <module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in
<module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in
__bootstrap__
ImportError: dynamic module does not define init function (init_mysql)
Has anyone solved this? I been hunting around for 2 weeks now, and my
deadline is looming grimly on the horizon :)

Geert

Mar 14 '08 #1
8 2787
Geert,

I've not seen this issue myself, however, you might get a little more luck
asking over on the MySQLdb mailing list as this seems to be more an issue
with the db than your python code. It might be worth posting your question
there too as it'll heighten your chances of finding someone who knows
MySQLdb inside out.

http://mail.python.org/mailman/listinfo/db-sig

Cheers,

Robert

-----Original Message-----
From: py************* *************** *************** **********@pyth on.org
[mailto:py****** *************** *************** *************** **@python.org]
On Behalf Of geert
Sent: 14 March 2008 10:36
To: py*********@pyt hon.org
Subject: Huge problem gettng MySQLdb to work on my mac mini running Macosx
10.5 Leopard

Hi all,

I have a mac mini running maocosx 10.5 leopard I want to deploy a
django project on. My backend is MySQL, and I have it running as a 64-
bit app. Of course, apache2 is also running as 64-bit.

MySQLdb installs with the usual warnings after applying the various
patches I found here and there. These patches consist of altering
_mysql.c and site.cfg.

Basically, my problem boils down to this:

File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py", line
19, in <module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in
<module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in
__bootstrap__
ImportError: dynamic module does not define init function (init_mysql)
Has anyone solved this? I been hunting around for 2 weeks now, and my
deadline is looming grimly on the horizon :)

Geert

--
http://mail.python.org/mailman/listinfo/python-list

Mar 14 '08 #2
On Mar 14, 11:49*am, "Robert Rawlins"
<robert.rawl... @thinkbluemedia .co.ukwrote:
Geert,

I've not seen this issue myself, however, you might get a little more luck
asking over on theMySQLdbmaili ng list as this seems to be more an issue
with the db than your python code. It might be worth posting your question
there too as it'll heighten your chances of finding someone who knowsMySQLdbins ide out.

http://mail.python.org/mailman/listinfo/db-sig

Cheers,

Robert

-----Original Message-----
From: python-list-bounces+robert. rawlins=thinkbl uemedia.co...@p ython.org

[mailto:python-list-bounces+robert. rawlins=thinkbl uemedia.co...@p ython.org]
On Behalf Of geert
Sent: 14 March 2008 10:36
To: python-l...@python.org
Subject: Huge problem gettngMySQLdbto work on my mac mini running Macosx
10.5 Leopard

Hi all,

I have a mac mini running maocosx 10.5 leopard I want to deploy a
django project on. My backend is MySQL, and I have it running as a 64-
bit app. Of course, apache2 is also running as 64-bit.

MySQLdbinstalls with the usual warnings after applying the various
patches I found here and there. These patches consist of altering
_mysql.c and site.cfg.

Basically, my problem boils down to this:

* File "<stdin>", line 1, in <module>
* File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py", line
19, in <module>
* File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in
<module>
* File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in
__bootstrap__
ImportError: dynamic module does not define init function (init_mysql)

Has anyone solved this? I been hunting around for 2 weeks now, and my
deadline is looming grimly on the horizon :)

Geert

--http://mail.python.org/mailman/listinfo/python-list
Thanks, Robert. I'm on the MySQLdb list, and am working on a solution.
And I've subscribed to the list you gave.

Geert

Mar 15 '08 #4
On Mar 14, 1:15*pm, martin.lal...@g mail.com wrote:
look athttp://groups.google.b e/group/comp.lang.pytho n/browse_thread/thread/d...

There is a macpython list that you can consult athttp://www.nabble.com/Python---pythonmac-sig-f2970.html
Just wanted to let you know that I've solved my problem. The solution
is to compile mysql using

MACOSX_DEPLOYME NT_TARGET=10.5 \
CFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking --enable-thread-safe-client
--prefix=/usr/local/mysql

You then go this way to get it running on your machine:

http://hivelogic.com/articles/instal...l-on-mac-os-x/

Then reinstall MySQLdb. Magic!

Geert

Mar 18 '08 #5
On Mar 18, 6:56*pm, geert <ge...@nznl.com wrote:
On Mar 14, 1:15*pm, martin.lal...@g mail.com wrote:
look athttp://groups.google.b e/group/comp.lang.pytho n/browse_thread/thread/d...
There is a macpython list that you can consult athttp://www.nabble.com/Python---pythonmac-sig-f2970.html

Just wanted to let you know that I've solved my problem. The solution
is to compile mysql using

MACOSX_DEPLOYME NT_TARGET=10.5 \
CFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking *--enable-thread-safe-client
--prefix=/usr/local/mysql

You then go this way to get it running on your machine:

http://hivelogic.com/articles/instal...l-on-mac-os-x/

Then reinstall MySQLdb. Magic!

Geert
Seems that I've yelled success to quickly. Everything's ok as long as
I just run the django dev server, but moving to apache through
mod_wsgi brings a well-known but less than comforting complaint:

[Tue Mar 18 23:34:25 2008] [error] [client ::1] mod_wsgi (pid=2352):
Exception occurred processing WSGI script '/Users/geert/Sites/LithoNET/
LN/LNApache.wsgi'. , referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] Traceback (most recent
call last):, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/core/handlers/wsgi.py", line 205, in
__call__, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] response =
self.get_respon se(request), referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/core/handlers/base.py", line 64, in
get_response, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] response =
middleware_meth od(request), referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/middleware.py", line
13, in process_request , referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] engine =
__import__(sett ings.SESSION_EN GINE, {}, {}, ['']), referer:
http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/backends/db.py", line
2, in <module>, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] from
django.contrib. sessions.models import Session, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/models.py", line 5,
in <module>, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] from django.db
import models, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/db/__init__.py", line 17, in <module>,
referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] backend =
__import__('%s% s.base' % (_import_path, settings.DATABA SE_ENGINE), {},
{}, ['']), referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/db/backends/mysql/base.py", line 12,
in <module>, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] raise
ImproperlyConfi gured("Error loading MySQLdb module: %s" % e), referer:
http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfi gured:
Error loading MySQLdb module: dlopen(/Library/WebServer/.python-eggs/
MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): no
suitable image found. Did find:, referer: http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] \t/Library/
WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-
tmp/_mysql.so: no matching architecture in universal wrapper, referer:
http://localhost/images/

mmmmmm
Geert
Mar 18 '08 #6
On Mar 19, 9:47 am, geert <ge...@nznl.com wrote:
On Mar 18, 6:56 pm, geert <ge...@nznl.com wrote:
On Mar 14, 1:15 pm, martin.lal...@g mail.com wrote:
look athttp://groups.google.b e/group/comp.lang.pytho n/browse_thread/thread/d...
There is a macpython list that you can consult athttp://www.nabble.com/Python---pythonmac-sig-f2970.html
Just wanted to let you know that I've solved my problem. The solution
is to compile mysql using
MACOSX_DEPLOYME NT_TARGET=10.5 \
CFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking --enable-thread-safe-client
--prefix=/usr/local/mysql
You then go this way to get it running on your machine:
http://hivelogic.com/articles/instal...l-on-mac-os-x/
Then reinstall MySQLdb. Magic!
Geert

Seems that I've yelled success to quickly. Everything's ok as long as
I just run the django dev server, but moving to apache throughmod_wsgi brings a well-known but less than comforting complaint:

[Tue Mar 18 23:34:25 2008] [error] [client ::1]mod_wsgi(pid=23 52):
Exception occurred processing WSGI script '/Users/geert/Sites/LithoNET/
LN/LNApache.wsgi'. , referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] Traceback (most recent
call last):, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/core/handlers/wsgi.py", line 205, in
__call__, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] response =
self.get_respon se(request), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/core/handlers/base.py", line 64, in
get_response, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] response =
middleware_meth od(request), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/middleware.py", line
13, in process_request , referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] engine =
__import__(sett ings.SESSION_EN GINE, {}, {}, ['']), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/backends/db.py", line
2, in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] from
django.contrib. sessions.models import Session, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/models.py", line 5,
in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] from django.db
import models, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/db/__init__.py", line 17, in <module>,
referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] backend =
__import__('%s% s.base' % (_import_path, settings.DATABA SE_ENGINE), {},
{}, ['']), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/db/backends/mysql/base.py", line 12,
in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] raise
ImproperlyConfi gured("Error loading MySQLdb module: %s" % e), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfi gured:
Error loading MySQLdb module: dlopen(/Library/WebServer/.python-eggs/
MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): no
suitable image found. Did find:, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] \t/Library/
WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-
tmp/_mysql.so: no matching architecture in universal wrapper, referer:http://localhost/images/
Did you again confirm that running:

file /Library/WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-
macosx-10.5-i386.egg-tmp/_mysql.so

shows the .so having the required architectures, specifically what
Apache runs as (eg. x86_64)?

Do the gcc compiler flags when building and linking the .so file show
all the architecture flags?

Have you empty the Python egg cache to make sure it isn't an older
compiled version?

Graham

Mar 19 '08 #7
On Mar 19, 2:26*am, Graham Dumpleton <Graham.Dumple. ..@gmail.com>
wrote:
On Mar 19, 9:47 am, geert <ge...@nznl.com wrote:
On Mar 18, 6:56 pm, geert <ge...@nznl.com wrote:
On Mar 14, 1:15 pm, martin.lal...@g mail.com wrote:
look athttp://groups.google.b e/group/comp.lang.pytho n/browse_thread/thread/d...
There is a macpython list that you can consult athttp://www.nabble.com/Python---pythonmac-sig-f2970.html
Just wanted to let you know that I've solved my problem. The solution
is to compile mysql using
MACOSX_DEPLOYME NT_TARGET=10.5 \
CFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking *--enable-thread-safe-client
--prefix=/usr/local/mysql
You then go this way to get it running on your machine:
>http://hivelogic.com/articles/instal...l-on-mac-os-x/
Then reinstall MySQLdb. Magic!
Geert
Seems that I've yelled success to quickly. Everything's ok as long as
I just run the django dev server, but moving to apache throughmod_wsgi brings a well-known but less than comforting complaint:
[Tue Mar 18 23:34:25 2008] [error] [client ::1]mod_wsgi(pid=23 52):
Exception occurred processing WSGI script '/Users/geert/Sites/LithoNET/
LN/LNApache.wsgi'. , referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] Traceback (most recent
call last):, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * File "/Library/
Python/2.5/site-packages/django/core/handlers/wsgi.py", line 205, in
__call__, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * * response =
self.get_respon se(request), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * File "/Library/
Python/2.5/site-packages/django/core/handlers/base.py", line 64, in
get_response, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * * response =
middleware_meth od(request), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * File "/Library/
Python/2.5/site-packages/django/contrib/sessions/middleware.py", line
13, in process_request , referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * * engine =
__import__(sett ings.SESSION_EN GINE, {}, {}, ['']), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * File "/Library/
Python/2.5/site-packages/django/contrib/sessions/backends/db.py", line
2, in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * * from
django.contrib. sessions.models import Session, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * File "/Library/
Python/2.5/site-packages/django/contrib/sessions/models.py", line 5,
in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * * from django.db
import models, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * File "/Library/
Python/2.5/site-packages/django/db/__init__.py", line 17, in <module>,
referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * * backend =
__import__('%s% s.base' % (_import_path, settings.DATABA SE_ENGINE), {},
{}, ['']), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * File "/Library/
Python/2.5/site-packages/django/db/backends/mysql/base.py", line 12,
in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] * * raise
ImproperlyConfi gured("Error loading MySQLdb module: %s" % e), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfi gured:
Error loading MySQLdb module: dlopen(/Library/WebServer/.python-eggs/
MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): no
suitable image found. *Did find:, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] \t/Library/
WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-
tmp/_mysql.so: no matching architecture in universal wrapper, referer:http://localhost/images/

Did you again confirm that running:

* file /Library/WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-
macosx-10.5-i386.egg-tmp/_mysql.so

shows the .so having the required architectures, specifically what
Apache runs as (eg. x86_64)?

Do the gcc compiler flags when building and linking the .so file show
all the architecture flags?

Have you empty the Python egg cache to make sure it isn't an older
compiled version?

Graham
Hi all,

GOT IT!

I have every running now. So, to sum it all up:

I'm on a new intel mac with a 64-bit capable processor running macosx
10.5.2.

I have httpd (apache2) running as a 64 bit app, which it would of
course on a 64-bit machine. Activity monitor confirms this.

I compiled mysql from source, configured as stated below:

MACOSX_DEPLOYME NT_TARGET=10.5 \
CFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking --enable-thread-safe-
client
--prefix=/usr/local/mysql

Then came mod_wsgi, just out of the box.

Then came MySQLdb.

Extracted the tar, then edited _mysql.c. Commented lines 37 - 39:

//#ifndef uint
//#define uint unsigned int
//#endif

and changed this:
uint port = MYSQL_PORT;
uint client_flag = 0;

to this:
unsigned int port = MYSQL_PORT;
unsigned int client_flag = 0;

on lines 484 and 485

Then - but I don't know if this is really (always) necessary, in
site.cfg I changed Threadsafe = True to False.

I set the ARCHFLAGS, but I don't think this helped one inch.

ARCHFLAGS='-arch ppc -arch ppc64 -arch i386 -arch x86_64'
OK. So then I went sudo python setup.py build. (I realise that the
sudo isn't required just to do a build)

There, I noticed this:

creating build/temp.macosx-10.5-i386-2.5
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -
DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -
Dversion_info=( 1,2,2,'final',0 ) -D__version__=1. 2.2 -I/usr/local/mysql/
include/mysql -I/System/Library/Frameworks/Python.framewor k/Versions/
2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/
_mysql.o -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64

You see, here _mysql.o is being created. If you do file _mysql.o, you
get:

/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o: Mach-O universal binary with 4 architectures
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture i386): Mach-O object i386
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture x86_64): Mach-O 64-bit object
x86_64
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture ppc7400): Mach-O object ppc
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture ppc64): Mach-O 64-bit object ppc64

which is ok.

But, strangely, when _mysql.so is created in the next step, gcc
doesn't add all the arch flags:

gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc
build/temp.macosx-10.5-i386-2.5/_mysql.o -L/usr/local/mysql/lib/mysql -
lmysqlclient -lz -lm -o build/lib.macosx-10.5-i386-2.5/_mysql.so

and you end up with this:

geert-dekkerss-imac:MySQL-python-1.2.2 geert$ file /Users/geert/
Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/_mysql.so
/Users/geert/Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/
_mysql.so: Mach-O universal binary with 2 architectures
/Users/geert/Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/
_mysql.so (for architecture i386): Mach-O bundle i386
/Users/geert/Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/
_mysql.so (for architecture ppc7400): Mach-O bundle ppc

which is most definitely NOT ok.

So I did this:

sudo gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch ppc -arch
ppc64 -arch i386 -arch x86_64 build/temp.macosx-10.5-i386-2.5/_mysql.o
-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -o build/
lib.macosx-10.5-i386-2.5/_mysql.so

adding the arch flags myself, and running gcc again, under sudo.

and lo and behold....

geert-dekkerss-imac:MySQL-python-1.2.2 geert$ file /Users/
geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/
_mysql.so
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so: Mach-O universal binary with 4 architectures
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture ppc7400): Mach-O bundle ppc
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture ppc64): Mach-O 64-bit bundle
ppc64
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture i386): Mach-O bundle i386
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture x86_64): Mach-O 64-bit bundle
x86_64
Well, it only took 20 years off my life span and all the hairs on my
head :)

Geert



Mar 19 '08 #8
On Mar 19, 9:30 pm, geert <ge...@nznl.com wrote:
On Mar 19, 2:26 am, Graham Dumpleton <Graham.Dumple. ..@gmail.com>
wrote:
On Mar 19, 9:47 am, geert <ge...@nznl.com wrote:
On Mar 18, 6:56 pm, geert <ge...@nznl.com wrote:
On Mar 14, 1:15 pm, martin.lal...@g mail.com wrote:
look athttp://groups.google.b e/group/comp.lang.pytho n/browse_thread/thread/d...
There is a macpython list that you can consult athttp://www.nabble.com/Python---pythonmac-sig-f2970.html
Just wanted to let you know that I've solved my problem. The solution
is to compile mysql using
MACOSX_DEPLOYME NT_TARGET=10.5 \
CFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking --enable-thread-safe-client
--prefix=/usr/local/mysql
You then go this way to get it running on your machine:
http://hivelogic.com/articles/instal...l-on-mac-os-x/
Then reinstall MySQLdb. Magic!
Geert
Seems that I've yelled success to quickly. Everything's ok as long as
I just run the django dev server, but moving to apache throughmod_wsgi brings a well-known but less than comforting complaint:
[Tue Mar 18 23:34:25 2008] [error] [client ::1]mod_wsgi(pid=23 52):
Exception occurred processing WSGI script '/Users/geert/Sites/LithoNET/
LN/LNApache.wsgi'. , referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] Traceback (most recent
call last):, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/core/handlers/wsgi.py", line 205, in
__call__, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] response =
self.get_respon se(request), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/core/handlers/base.py", line 64, in
get_response, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] response =
middleware_meth od(request), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/middleware.py", line
13, in process_request , referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] engine =
__import__(sett ings.SESSION_EN GINE, {}, {}, ['']), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/backends/db.py", line
2, in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] from
django.contrib. sessions.models import Session, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/contrib/sessions/models.py", line 5,
in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] from django.db
import models, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/db/__init__.py", line 17, in <module>,
referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] backend =
__import__('%s% s.base' % (_import_path, settings.DATABA SE_ENGINE), {},
{}, ['']), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] File "/Library/
Python/2.5/site-packages/django/db/backends/mysql/base.py", line 12,
in <module>, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] raise
ImproperlyConfi gured("Error loading MySQLdb module: %s" % e), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfi gured:
Error loading MySQLdb module: dlopen(/Library/WebServer/.python-eggs/
MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): no
suitable image found. Did find:, referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] \t/Library/
WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-
tmp/_mysql.so: no matching architecture in universal wrapper, referer:http://localhost/images/
Did you again confirm that running:
file /Library/WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-
macosx-10.5-i386.egg-tmp/_mysql.so
shows the .so having the required architectures, specifically what
Apache runs as (eg. x86_64)?
Do the gcc compiler flags when building and linking the .so file show
all the architecture flags?
Have you empty the Python egg cache to make sure it isn't an older
compiled version?
Graham

Hi all,

GOT IT!

I have every running now. So, to sum it all up:

I'm on a new intel mac with a 64-bit capable processor running macosx
10.5.2.

I have httpd (apache2) running as a 64 bit app, which it would of
course on a 64-bit machine. Activity monitor confirms this.

I compiled mysql from source, configured as stated below:

MACOSX_DEPLOYME NT_TARGET=10.5 \
CFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --disable-dependency-tracking --enable-thread-safe-
client
--prefix=/usr/local/mysql

Then camemod_wsgi, just out of the box.

Then came MySQLdb.

Extracted the tar, then edited _mysql.c. Commented lines 37 - 39:

//#ifndef uint
//#define uint unsigned int
//#endif

and changed this:
uint port = MYSQL_PORT;
uint client_flag = 0;

to this:
unsigned int port = MYSQL_PORT;
unsigned int client_flag = 0;

on lines 484 and 485

Then - but I don't know if this is really (always) necessary, in
site.cfg I changed Threadsafe = True to False.

I set the ARCHFLAGS, but I don't think this helped one inch.

ARCHFLAGS='-arch ppc -arch ppc64 -arch i386 -arch x86_64'

OK. So then I went sudo python setup.py build. (I realise that the
sudo isn't required just to do a build)

There, I noticed this:

creating build/temp.macosx-10.5-i386-2.5
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -
DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -
Dversion_info=( 1,2,2,'final',0 ) -D__version__=1. 2.2 -I/usr/local/mysql/
include/mysql -I/System/Library/Frameworks/Python.framewor k/Versions/
2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/
_mysql.o -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64

You see, here _mysql.o is being created. If you do file _mysql.o, you
get:

/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o: Mach-O universal binary with 4 architectures
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture i386): Mach-O object i386
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture x86_64): Mach-O 64-bit object
x86_64
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture ppc7400): Mach-O object ppc
/Users/geert/Desktop/MySQL-python-1.2.2/build/temp.macosx-10.5-
i386-2.5/_mysql.o (for architecture ppc64): Mach-O 64-bit object ppc64

which is ok.

But, strangely, when _mysql.so is created in the next step, gcc
doesn't add all the arch flags:

gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc
build/temp.macosx-10.5-i386-2.5/_mysql.o -L/usr/local/mysql/lib/mysql -
lmysqlclient -lz -lm -o build/lib.macosx-10.5-i386-2.5/_mysql.so

and you end up with this:

geert-dekkerss-imac:MySQL-python-1.2.2 geert$ file /Users/geert/
Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/_mysql.so
/Users/geert/Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/
_mysql.so: Mach-O universal binary with 2 architectures
/Users/geert/Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/
_mysql.so (for architecture i386): Mach-O bundle i386
/Users/geert/Desktop/MySQL-python-1.2.2/build/lib.macosx-10.5-i386-2.5/
_mysql.so (for architecture ppc7400): Mach-O bundle ppc

which is most definitely NOT ok.

So I did this:

sudo gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch ppc -arch
ppc64 -arch i386 -arch x86_64 build/temp.macosx-10.5-i386-2.5/_mysql.o
-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -o build/
lib.macosx-10.5-i386-2.5/_mysql.so

adding the arch flags myself, and running gcc again, under sudo.

and lo and behold....

geert-dekkerss-imac:MySQL-python-1.2.2 geert$ file /Users/
geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/
_mysql.so
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so: Mach-O universal binary with 4 architectures
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture ppc7400): Mach-O bundle ppc
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture ppc64): Mach-O 64-bit bundle
ppc64
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture i386): Mach-O bundle i386
/Users/geert/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg-tmp/_mysql.so (for architecture x86_64): Mach-O 64-bit bundle
x86_64

Well, it only took 20 years off my life span and all the hairs on my
head :)
I don't have access to MacOS X OS supplied Python 2.5 at moment, but
if distutils used by setup.py is ignoring ARCHFLAGS for the link then
that may be an issue with distutils. More likely though is that MySQL
setup.py is setting some option which is causing ARCHFLAGS to be
ignored.

Strange thing is I can't find ARCHFLAGS in original Python 2.5 source
I have, so checking it may be specific to MacOS X OS supplied Python.

Will need to check when I get home to my Leopard box.

Graham
Mar 19 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1778
by: Stephan Diehl | last post by:
Since using Python2.3, MySQLdb doesn't work anymore correctly. Inserting data fails with "IndexError: list index out of range". Since the MySQLdb website states, that it runs up to version 2.2, I definatelly shouldn't complain :-) Is there somebody whose MySQLdb is running with 2.3? MySQLdb 0.9.2 Python 2.3 Linux
1
2595
by: Peter Nikolaidis | last post by:
Greetings, I am attempting to get MySQLdb 0.9.2 installed on Mac OS 10.2 with a Fink distribution of Python 2.2.2. I have seen only a few posts on the subject, some of them relate to "conflicting header files," but I don't know what to do about conflicting header files, or where I would find them, and once I found them, which ones to remove. I have compiled MySQL 4.1 and installed into /usr/local/mysql, but since have moved to a Fink...
1
2753
by: Steve | last post by:
Darwin steve.local 8.3.0 Darwin Kernel Version 8.3.0: Mon Oct 3 20:04:04 PDT 2005; root:xnu-792.6.22.obj~2/RELEASE_PPC Power Macintosh powerpc MacOSX 10.4.3 mysql Ver 14.7 Distrib 4.1.14, for apple-darwin8.2.0 (powerpc) using readline 4.3 runing the software gives me steve:~/MySQL-python-1.2.0 steve$ python setup.py build
2
4524
by: Mondal | last post by:
Hi, I am using MySQL 5.0 beta and Active Python 2.4. I have the correct version of MySQLdb installed. The problem is that I can't connect to MySQL through the Active Python interactive window. Here is a sample error: >>> c=MySQLdb.Connect(host='localhost',user='root',passwd='',db='shop',port=3306) Traceback (most recent call last):
1
702
by: Yi Xing | last post by:
Hi, I met the following error when I tried to install MySQLdb. I had no problem installing numarray, Numeric, Rpy, etc. Does anyone know what's the problem? Thanks! running install running build running build_py creating build
2
3687
by: Martin Kulas | last post by:
Hallo! I have a problem with Py_BuildValue: I want to convert an unsigned int to a PyObject *. http://docs.python.org/api/arg-parsing.html says that I can use "I" as a format string. But it does not work :-\ Here is my simplified code:
1
2137
by: Ted Zeng | last post by:
Hi, I am new to Python. I am trying to build MySQLdb for my PowerPC PowerMac. I just downloaded the source last week and tried to build it. But I got the error messages as follow. I checked and there is no such files as mysql_config mysql.h my_config.h
0
1151
by: Tommy Grav | last post by:
I am trying to install mysqldb-1.2.2 on my PPC running 10.5.2 and Activepython 2.5.1.1 when I get this error: running build running build_py copying MySQLdb/release.py -build/lib.macosx-10.3-fat-2.5/MySQLdb running build_ext building '_mysql' extension gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -
1
2956
by: cnivas | last post by:
Hi, I'm doing a small project on Python using MySQL as Database in MAC OS X. I was unable to connect the database. I was downloaded MySQLdb from sourceforge.net and I also modified setup_posix.py. After modified and restart the setup.py I'm getting an error "gcc" cannot find the file. This is the error it was getting when I was reinstalling the setup.py "Administrator:MySQL-python-1.2.2 administrator$ sudo python setup.py install running...
0
10480
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9658
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8034
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7187
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5876
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3303
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.