I was able to get django/python running via mod_python under the
apache2 installation under Leopard (MacOS X 10.5). However once I
start to add database support to my project - I get the following
error.
ImproperlyConfigured: Error loading MySQLdb module: dlopen(/tmp/
egg_cache/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so,
2): no suitable image found. Did find:
/tmp/egg_cache/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/
_mysql.so: no matching architecture in universal wrapper
Anyone have any luck figuring this out?
Thanks,
Chris.
-- Full Error Listing --
MOD_PYTHON ERROR
ProcessId: 28674
Interpreter: 'mysite'
ServerName: 'Lepperd.local'
DocumentRoot: '/Library/WebServer/Documents'
URI: '/webdocs/mysite/'
Location: '/webdocs/mysite'
Directory: None
Filename: '/Library/WebServer/Documents/webdocs/mysite/'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1128, in _execute_target
result = object(arg)
File "/Library/Python/2.5/site-packages/django/core/handlers/
modpython.py", line 177, in handler
return ModPythonHandler()(req)
File "/Library/Python/2.5/site-packages/django/core/handlers/
modpython.py", line 145, in __call__
self.load_middleware()
File "/Library/Python/2.5/site-packages/django/core/handlers/
base.py", line 29, in load_middleware
mod = __import__(mw_module, {}, {}, [''])
File "/Library/Python/2.5/site-packages/django/contrib/sessions/
middleware.py", line 2, in <module>
from django.contrib.sessions.models import Session
File "/Library/Python/2.5/site-packages/django/contrib/sessions/
models.py", line 3, in <module>
from django.db import models
File "/Library/Python/2.5/site-packages/django/db/__init__.py", line
11, in <module>
backend = __import__('django.db.backends.%s.base' %
settings.DATABASE_ENGINE, {}, {}, [''])
File "/Library/Python/2.5/site-packages/django/db/backends/mysql/
base.py", line 12, in <module>
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
ImproperlyConfigured: Error loading MySQLdb module: dlopen(/tmp/
egg_cache/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so,
2): no suitable image found. Did find:
/tmp/egg_cache/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/
_mysql.so: no matching architecture in universal wrapper
How did you install the MySQL/Python library? Did you use MacPorts? A
pre-made binary?
http://dotnet.org.za/ncode/archive/2007/01/31/setting-up-mysql-for-python-mysqldb-on-mac-os-x-2.aspx
The comments on it were really the key.
Under Leopard (10.5) apache2 is 4-way, so it is running in 64-bit
mode. I haven't been able to figure out how to pass the right
architecture flags through setup.py
cc -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 -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 -Os -arch i386 -fno-common
gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc -
arch ppc64 -arch x86_64 build/temp.macosx-10.5-i386-2.5/_mysql.o -L/
usr/local/mysql/lib/mysql -lmysqlclient_r -lz -lm -o build/
lib.macosx-10.5-i386-2.5/_mysql.so
ld: warning in build/temp.macosx-10.5-i386-2.5/_mysql.o, file is not
of required architecture
ld: warning in /usr/local/mysql/lib/mysql/libmysqlclient_r.dylib, file
is not of required architecture
ld: warning in build/temp.macosx-10.5-i386-2.5/_mysql.o, file is not
of required architecture
ld: warning in /usr/local/mysql/lib/mysql/libmysqlclient_r.dylib, file
is not of required architecture
ld: warning in build/temp.macosx-10.5-i386-2.5/_mysql.o, file is not
of required architecture
ld: warning in /usr/local/mysql/lib/mysql/libmysqlclient_r.dylib, file
is not of required architecture
Short answer is, try editing src/Makefile in mod_python after running
configure and change:
mod_python.so: $(SRCS)
@echo
@echo 'Compiling for DSO.'
@echo
$(APXS) $(INCLUDES) -c $(SRCS) $(LDFLAGS) $(LIBS)
@rm -f mod_python.so
@ln -s .libs/mod_python.so mod_python.so
to:
mod_python.so: $(SRCS)
@echo
@echo 'Compiling for DSO.'
@echo
$(APXS) $(INCLUDES) -c -Wc,"-arch ppc" -Wc,"-arch ppc64" -Wc,"-
arch i386" -Wc,"-arch x86_64" $(SRCS) $(LDFLAGS) $(LIBS)
@rm -f mod_python.so
@ln -s .libs/mod_python.so mod_python.so
Ie., add the arch options in explicitly.
Recompile and reinstall mod_python and see if that makes a difference.
Graham
On Oct 31, 6:57 am, crudolph <chris.rudo...@gmail.com> wrote:
> Yeah - I downloaded fromhttp://sourceforge.net/projects/mysql-python,
Reading this again, what do you get if run run:
file /usr/local/mysql/lib/mysql/libmysqlclient_r.dylib
The problem is not necessarily passing correct arch flags through
setup.py but that the MySQL client library doesn't contain all
architectures and needs to be recompiled.
Graham
I'm guessing you d/l'd and installed the MySQL OSX 10.4 x86 installer
package from MySQL. I did. I think it's only i386.
They also have a Universal Binary OSX 10.4 file up there, but only in
Tar format. I'm d/l'ing that now to try. Hopefully it's got the
x86_64 image in it as well.
-Ben
[Macintosh:src/mysql-5.0.45-osx10.4-universal/lib] benha% file
libmysqlclient_r.a
libmysqlclient_r.a: Mach-O universal binary with 3 architectures
libmysqlclient_r.a (for architecture i386): current ar archive
libmysqlclient_r.a (for architecture ppc64): current ar archive
libmysqlclient_r.a (for architecture ppc): current ar archive
So that means that in order to link to the MySQL libs, we'll need to
build/install a 64-bit version of MySQL. Sigh...
Anyone have a set of reliable, working instructions for doing that?
-Ben
Download the Community Server Source and you can build it from that.
I hade the same problem but for QT and MySQL support,
take a look at, http://demo.grenangen.se/drupal
There you will find a simple instruction set on how to build the
community server source for Leopard.
If that doesn't help, get back to me and I'll try to help further.