如何升级Apache使用的Python版本?
在 Red hat 机器上,我将 Python 从 2.3 升级到 2.6.4,并将符号链接更改为 python
,因此当我输入 python
时,会出现 2.6.4 解释器。
但是,我的 .py 文件可以在命令行中运行,但不能在浏览器中运行。这似乎是一个 sys.path
问题,因此我在浏览器中打开该文件并打印出 sys.path
。
令人惊讶的是,从浏览器调用时与从命令行调用时我的 sys.path 是不同的。因为路径都指向 2.3,所以我相信 Apache 正在选择 Python 2.3,而不是我安装的新 2.6.4 版本。
如何让 Apache 使用 Python 2.6.4?
On a Red hat box, I upgraded Python from 2.3 to 2.6.4 and changed the symlink to python
so when I type in python
the 2.6.4 interpreter comes up.
However my .py file works from the command-line, but not in the browser. It seemed like a sys.path
issue so I opened the file in a browser and printed out sys.path
.
Surprisingly, my sys.path
is different when called from a browser than when called from a command-line. Because the paths are all referring to 2.3, I believe Apache is picking up Python 2.3 rather than the new 2.6.4 version I installed.
How do I make Apache use Python 2.6.4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用
mod_python
或mod_wsgi
,您应该重新安装它们,因为它们可能是根据您安装时的 Python 版本构建的首先安装在系统上(在您的情况下似乎是 Python 2.3)。If you're using
mod_python
ormod_wsgi
, you should reinstall them as they've probably been built to the python version you had when they were first installed on the system (which in your case appears to be Python 2.3).Apache 不直接调用 python,因此路径无关紧要。您可能想要自己构建一个新的 mod_wsgi 来链接 python 2.6.4。
Apache isn't calling python directly, so the path is irrelevant. You will probably want to build yourself a new mod_wsgi to link against python 2.6.4.
在 RH 机器上,Apache 可能以 root 用户身份运行。以 root 身份登录并查看 root 看到的 python 版本。
嗨
..里奇
On RH box Apache probably runs as root user. Login as root and see which version of python root sees.
HIH
..richie