BTW, the virtualenv uses python2.7
On Wed, Aug 24, 2011 at 6:54 PM, Jianbao Tao <jianbao....@gmail.com> wrote: > Thanks, Tom, Reinout. > > I think I forgot to mention the configuration of my machine. Here it is. > > - Mac OS Snow Leopard 10.6.8 > - mysql-5.5.14-osx10.6-x86_64 > - Apache2 (shipped with OSX) > - mod_wsgi 3.3 > > And here is some additional information that may help. > <shell> > >$ file /usr/libexec/apache2/mod_wsgi.so > /usr/libexec/apache2/mod_wsgi.so: Mach-O universal binary with 2 > architectures > /usr/libexec/apache2/mod_wsgi.so (for architecture x86_64): Mach-O 64-bit > bundle x86_64 > /usr/libexec/apache2/mod_wsgi.so (for architecture i386): Mach-O bundle > i386 > > >$ otool -L /usr/libexec/apache2/mod_wsgi.so > /usr/libexec/apache2/mod_wsgi.so: > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version > 125.2.11) > /Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility > version 2.7.0, current version 2.7.0) > /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation > (compatibility version 150.0.0, current version 550.43.0) > </shell> > > And I do use virtualenv. Here is how I enable the virtual environment in > the .wsgi file. > <code> > """ > Modify sys.path to conform to virtualenv setup. > The basic idea is to add packages installed in the virtual environment to > the > front of sys.path so that python will use them instead of those from the > system site-packages. > """ > # Get old sys.path. > old_sys_path = list(sys.path) > virt_site_packages = os.path.join(path, siteName, > 'lib/python2.7/site-packages') > > site.addsitedir(virt_site_packages) > > # Put the added new paths to the front of sys.path. > new_sys_path = [] > for item in list(sys.path): > if item not in old_sys_path: > new_sys_path.append(item) > sys.path.remove(item) > > sys.path[:0] = new_sys_path > </code> > > The process is pretty standard, which can be found in the mod_wsgi > website<http://code.google.com/p/modwsgi/wiki/VirtualEnvironments> > . > > So, any thoughts? > > > On Wed, Aug 24, 2011 at 10:25 AM, Tom Evans <tevans...@googlemail.com>wrote: > >> On Mon, Aug 22, 2011 at 11:37 PM, Jim <jianbao....@gmail.com> wrote: >> > Hello folks, >> > This probably has been discussed many times, but I still can't find any >> > solution yet. Basically, it turns out that python can load MySQLdb just >> > fine, but Apache can't load MySQLdb from the wsgi script. >> > I am using python2.7 in a virtual environment created by virtualenv. >> Here is >> > the error info extracted from the Apache error log. To make the lines >> > shorter, I deleted all the time tags in the brackets. >> > Any ideas how to fix it? >> > [] mod_wsgi (pid=3136): Target WSGI script >> > '/Users/jianbao/projects/tao.com/mysite/apache/django.wsgi' cannot be >> loaded >> > as Python module. >> > [] mod_wsgi (pid=3136): Exception occurred processing WSGI script >> > '/Users/jianbao/projects/tao.com/mysite/apache/django.wsgi'. >> > [] Traceback (most recent call last): >> > [] File "/Users/jianbao/projects/tao.com/mysite/apache/django.wsgi", >> line >> > 56, in <module> >> > [] import MySQLdb >> > [] File >> > "/Users/jianbao/projects/ >> tao.com/mysite/lib/python2.7/site-packages/MySQLdb/__init__.py", >> > line 19, in <module> >> > [] import _mysql >> > [] ImportError: >> > dlopen(/Users/jianbao/projects/ >> tao.com/mysite/lib/python2.7/site-packages/_mysql.so, >> > 2): Library not loaded: libmysqlclient.18.dylib >> > [] Referenced from: >> > /Users/jianbao/projects/ >> tao.com/mysite/lib/python2.7/site-packages/_mysql.so >> > [] Reason: image not found >> > >> >> Are mysql, python and python-mysql all compiled correctly for the same >> architecture? IE all 32 bit or all 64 bit. >> >> ISTR that this can be a problem on OS X, but I'm not an OS X user... >> >> >> http://stackoverflow.com/questions/1969222/mysql-python-1-2-3-and-os-x-10-5-64-or-32-bit >> >> Cheers >> >> Tom >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.