简体   繁体   English

金字塔框架:Apache + mod_wsgi - MySQLdb导入错误

[英]Pyramid framework : Apache + mod_wsgi - MySQLdb import error

This is my first pyramid application and I have tried what ever solution I could find but none are working for me. 这是我的第一个金字塔应用程序,我已经尝试了我能找到的解决方案,但没有一个适合我。 I keep getting internal server error and error logs show this : 我一直收到内部服务器错误,错误日志显示:

Tue Jul 31 02:02:23 2012] [error] [client 127.0.0.1]     import MySQLdb as mysql
[Tue Jul 31 02:02:23 2012] [error] [client 127.0.0.1]   File "build/bdist.macosx-10.7-            intel/egg/MySQLdb/__init__.py", line 19, in <module>
[Tue Jul 31 02:02:23 2012] [error] [client 127.0.0.1]   File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in <module>
[Tue Jul 31 02:02:23 2012] [error] [client 127.0.0.1]   File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in __bootstrap__
[Tue Jul 31 02:02:23 2012] [error] [client 127.0.0.1] ImportError: dlopen(/Users/anupamtulsyan/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
[Tue Jul 31 02:02:23 2012] [error] [client 127.0.0.1]   Referenced from: /Users/anupamtulsyan/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
[Tue Jul 31 02:02:23 2012] [error] [client 127.0.0.1]   Reason: image not found
[Tue Jul 31 02:02:24 2012] [error] [client 127.0.0.1] File does not exist: /opt/local/apache2/htdocs/favicon.ico

Both my mysql and python are 64 bit installation. 我的mysql和python都是64位安装。 The file 'libmysqlclient.18.dylib' exists in /usr/local/mysql/lib. 文件'libmysqlclient.18.dylib'存在于/ usr / local / mysql / lib中。 I am able to import MySQLdb while serving the application using : ../bin/pserver development.ini However when running through mod_wsgi the above error keeps coming. 我可以使用以下命令在服务应用程序时导入MySQLdb:../ bin / pserver development.ini但是当运行mod_wsgi时,上述错误不断出现。 Please someone help ! 请有人帮忙! I have been stuck on this since 2 days. 自从2天以来我一直坚持这个。

It looks like the libmysqlclient.18.dylib is not on Apache's path. 看起来libmysqlclient.18.dylib不在Apache的路径上。 So you probably need to set it in /usr/sbin/envvars something like: 所以你可能需要在/usr/sbin/envvars设置它:

DYLD_LIBRARY_PATH="/usr/lib:/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

depending on where your mysql lib is and then restart apache. 取决于你的mysql lib的位置,然后重启apache。

I think you may also be able to set DYLD_RUN_PATH before building MySQLdb and it will use that path in the _mysql.so -- obviating the need to set DYLD_LIBRARY_PATH 我想你也可以在构建DYLD_RUN_PATH之前设置DYLD_RUN_PATH在_mysql.so中使用该路径 - 无需设置DYLD_LIBRARY_PATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM