如何在Web服务器上设置PYTHONPATH

时间:2023-01-19 23:11:26

I have been running Apache and PHP successfully for a while and would now like to use python as well. I have installed django and mod_wsgi, but still haven't got them working.

我已成功运行Apache和PHP一段时间了,现在也想使用python。我已经安装了django和mod_wsgi,但仍然没有让它们正常工作。

I get errors like

我得到的错误就像

ImportError: Could not import settings '/srv/django_projects/proj1/settings.py' (Is it on sys.path?):

in my apache logs. Tutorials about setting PYTHONPATH seem to require adding an export command to webserver startup scripts, but frankly I have no idea what I'm doing so I'd like to get some clarity about what's going on, and what I should do.

在我的apache日志中。关于设置PYTHONPATH的教程似乎需要向webserver启动脚本添加导出命令,但坦率地说我不知道​​我在做什么,所以我想清楚一下发生了什么,以及我应该做些什么。

1 个解决方案

#1


0  

Use a virtual environment as documented in:

使用如下所述的虚拟环境:

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

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

Also see:

另见:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonPath

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonPath

and the python-path option of:

和python-path选项:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

Which of the latter you might use depends on how you are running mod_wsgi.

您可能使用的后者中的哪一个取决于您运行mod_wsgi的方式。

So, lots of documentation available.

所以,有很多文档可供使用。

#1


0  

Use a virtual environment as documented in:

使用如下所述的虚拟环境:

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

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

Also see:

另见:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonPath

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonPath

and the python-path option of:

和python-path选项:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

Which of the latter you might use depends on how you are running mod_wsgi.

您可能使用的后者中的哪一个取决于您运行mod_wsgi的方式。

So, lots of documentation available.

所以,有很多文档可供使用。