【发布时间】:2015-02-04 16:51:35
【问题描述】:
我有一个网站,我的网站下的 cgi-bin 文件夹中有 2 个 python cgi 脚本。现在每次它尝试加载这两个 python cgi scipts 中的任何一个时,服务器都会返回 500 错误,并且错误的过早结束臭名昭著的错误。
所以我尝试了一些新的东西。我做了一个非常简单的python cgi-script:
#!/usr/bin/python -u
print "Content-type: text/html\n\n"
print "Hello World!"
我将它命名为hello_world.py,将它与其他2 个python 脚本一起放入cgi-bin,然后运行以下链接:http://steap.co/cgi-bin/hello_world.py,它惊人地返回了“Hello World!”。
这表明我的 python 脚本有问题,但我不知道是什么。这是我的脚本:
Steap.py
#!/usr/bin/python -u
#Steam64 ID - 76561198041707719
import urllib
import cgi, cgitb
import itertools
import urllib2
import time
from datetime import datetime
from bs4 import BeautifulSoup
from flask import Flask, jsonify, render_template, redirect
import requests
import json
import xml.etree.ElementTree as ET
from xml.dom.minidom import parseString
import sys
//code goes here
print "Content-type: text/html\n\n"
print "<div id=\"phisher-users\"></br></br>"
print getFriendList(steeam)
print "</div>"
print "<div id=\"phisher-ids\" style=\"display: none;\">"
print grabPhisherIDs()
print "</div>"
现在,当服务器尝试加载此脚本时,我得到了更多信息:
Traceback (most recent call last):
File "Steap.py", line 9, in
from bs4 import BeautifulSoup
ImportError: No module named bs4
[Sat Dec 06 09:58:07 2014] [error] [client 174.61.70.33] Premature end of script headers: Steap.py
为什么会这样?我在我的网站中自定义安装了python 2.7,并且我对上面所有的自定义模块(例如bs4、flask等)都使用了pip。
非常感谢任何帮助。
【问题讨论】:
-
你可以尝试运行 pip freeze 命令,看看它显示的是 bs4 还是 BeautifulSoup。
-
@TanveerAlam 我该怎么做?
-
只需转到命令提示符并输入
pip freeze,然后按回车键。 -
@TanveerAlam 好的,我看到了
BeautifulSoup==3.2.1和beautifulsoup4==4.3.2