开发者

stumped by WSGI module import errors

开发者 https://www.devze.com 2023-01-01 08:46 出处:网络
I\'m writing a bare bones Python wsgi application and am getting stumped by module import errors. I have a .py file in the current directory which initially failed to import. By adding

I'm writing a bare bones Python wsgi application and am getting stumped by module import errors. I have a .py file in the current directory which initially failed to import. By adding

sys.path.insert(0, '/Users/guhar/S开发者_StackOverflowites/acom')

the import of the module worked. But I now try and import a module that I had installed via easy_install and it fails to import. I tried setting

sys.path.insert(0, '/Library/Python/2.5/site-packages/')

which contains the egg file, but to no avail. I would've thought that all packages under "/Library/Python/2.5/site-packages/" would be available to a WSGI application.

Does anybody have any pointers?


Read:

http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

You cant simply add Python module directories containing .pth files into sys.path. You must use site.addsitedir() or use other options of mod_wsgi to have it use the virtual environment.

I think though perhaps, given that it looks like you are using MacOS X, that you have installed a second installation of Python and whatever mod_wsgi is using is not the version you have installed your packages into. That or your second Python installation is broken which often can be the case on MacOS X.

BTW, I am assuming that when you say WSGI you actually mean mod_wsgi given the tag you used. If you do, please do not use WSGI to refer to mod_wsgi. WSGI is a specification only, mod_wsgi is a specific hosting implementation. You should not be using the terms interchangeably.


If you're running under Apache mod_wsgi, specify all necessary python paths in your virtual host configuration like this:

WSGIDaemonProcess ... python-path=/srv/lala/www:/srv/lala/lib/python2.6/site-packages:/Library/Python/2.5/site-packages
0

精彩评论

暂无评论...
验证码 换一张
取 消