473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2752
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************************************************ *****@python.org
[mailto:py***************************************** ************@python.org]
On Behalf Of geert
Sent: 14 March 2008 10:36
To: py*********@python.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 theMySQLdbmailing 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 knowsMySQLdbinside out.

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

Cheers,

Robert

-----Original Message-----
From: python-list-bounces+robert.rawlins=thinkbluemedia.co...@python .org

[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co...@python .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...@gmail.com wrote:
look athttp://groups.google.be/group/comp.lang.python/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_DEPLOYMENT_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.comwrote:
On Mar 14, 1:15*pm, martin.lal...@gmail.com wrote:
look athttp://groups.google.be/group/comp.lang.python/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_DEPLOYMENT_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_response(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_method(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__(settings.SESSION_ENGINE, {}, {}, ['']), 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.DATABASE_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
ImproperlyConfigured("Error loading MySQLdb module: %s" % e), referer:
http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfigured:
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.comwrote:
On Mar 18, 6:56 pm, geert <ge...@nznl.comwrote:
On Mar 14, 1:15 pm, martin.lal...@gmail.com wrote:
look athttp://groups.google.be/group/comp.lang.python/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_DEPLOYMENT_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_wsgibrings 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_response(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_method(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__(settings.SESSION_ENGINE, {}, {}, ['']), 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.DATABASE_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
ImproperlyConfigured("Error loading MySQLdb module: %s" % e), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfigured:
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.comwrote:
On Mar 18, 6:56 pm, geert <ge...@nznl.comwrote:
On Mar 14, 1:15 pm, martin.lal...@gmail.com wrote:
look athttp://groups.google.be/group/comp.lang.python/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_DEPLOYMENT_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_wsgibrings 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_response(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_method(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__(settings.SESSION_ENGINE, {}, {}, ['']), 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.DATABASE_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
ImproperlyConfigured("Error loading MySQLdb module: %s" % e), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfigured:
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_DEPLOYMENT_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.framework/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.comwrote:
On Mar 19, 2:26 am, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:
On Mar 19, 9:47 am, geert <ge...@nznl.comwrote:
On Mar 18, 6:56 pm, geert <ge...@nznl.comwrote:
On Mar 14, 1:15 pm, martin.lal...@gmail.com wrote:
look athttp://groups.google.be/group/comp.lang.python/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_DEPLOYMENT_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_wsgibrings 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_response(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_method(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__(settings.SESSION_ENGINE, {}, {}, ['']), 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.DATABASE_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
ImproperlyConfigured("Error loading MySQLdb module: %s" % e), referer:http://localhost/images/
[Tue Mar 18 23:34:25 2008] [error] [client ::1] ImproperlyConfigured:
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_DEPLOYMENT_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.framework/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
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...
1
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...
1
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...
2
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. ...
1
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...
2
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...
1
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...
0
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...
1
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.