gpt4 book ai didi

python - Apache 使用 Python 2.4,Python 2.5 脚本失败

转载 作者:行者123 更新时间:2023-11-30 23:59:25 24 4
gpt4 key购买 nike

使用 CentOS5,我使用以下指令配置了 Apache。

Alias /pscript/ /var/www/pscript/
<Directory "/var/www/pscript/">
Options +ExecCGI
DirectoryIndex thetest.py
AddHandler cgi-script .py
</Directory>

当我调用 www.domain.com/pscript/时,我的 python 脚本会运行并打印出我的 sys.path,其中显示 python2.4

当我调用需要 Python 2.5 的不同脚本时,我收到 500 内部服务器错误。

查看我的 Apache error_log,我看到以下行:

[Wed Mar 03 16:58:44 2010] [error] [client 000.000.000.000] Please use Python 2.5 or greater

从命令行运行python -V 返回Python 2.5.5。我安装了 2.4 和 2.5.5,但应该只使用 2.5.5。

为了解决 Apache 问题,我重新编译了 Python 2.5.5 以确保安全,并确保启用共享库。然后我重新编译了 mod_python,以防影响某些内容,但我的 sys.path 仍然是 python2.4

我想知道,我需要重新编译 Apache 2.2.3 本身吗?我只需要 Apache 来使用 Python 2.5.5。

提前致谢。

最佳答案

Python 脚本的第一行是否类似于:

#!/usr/bin/python

如果是这样,也许/usr/bin/python是Python版本2.4,而直接从命令行运行python正在运行不同的Python可执行文件(版本2.5)来自您路径中的其他地方。尝试:

which python

从命令行运行 python 时查看正在运行的可执行文件。

关于python - Apache 使用 Python 2.4,Python 2.5 脚本失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2376768/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com