简体   繁体   English

Python脚本下载而不是运行?

[英]Python Script downloading instead of running?

I am running Python 2.7 in Tomcat 6, which I have done for a while, but for some reason now when I go to my pages the browser attempts to download the file instead of running the script. 我在Tomcat 6中运行了Python 2.7,这已经做了一段时间了,但是由于某种原因,当我进入页面时,浏览器尝试下载文件而不是运行脚本。 I can get a simple hello.py to work as such: 我可以得到一个简单的hello.py来这样工作:

#!/usr/bin/env python

print "Content-type: text/html\n\n"
print "<html>Hello World From CGI!</html>"

but if I try to add even just an import 但是如果我尝试仅添加导入

import MySQLdb

then the browser tries to download the file. 然后浏览器尝试下载文件。 Any idea what's going on? 知道发生了什么吗? How can I fix this? 我怎样才能解决这个问题?

Does maybe your import fail or something else in your script? 也许导入失败或脚本中出现其他错误? What is actually downloaded? 实际下载了什么? What do your logs say? 您的日志怎么说?

Imports were failing 进口失败

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM