Numpy 和 CGI​​ 的问题

发布于 2025-01-08 10:05:51 字数 668 浏览 3 评论 0原文

我决定创建一个项目,对用户的给定输入执行计算。

我安装了Python 2.7.2和Numpy 1.6.1。我正在运行安装了 apache2 的 Ubuntu 11.10 64 位。我的 .cgi 文件位于 /usr/lib/cgi-bin 中。 第一个脚本 math.cgi 如下所示:

#!/usr/bin/python

from numpy import *
from numpy.linalg import *
b = array([9,8])
a = array([[3,1], [1,2]])
x = solve(a,b)
print x

我可以通过在 /usr/lib/cgi-bin 中键入 python math.cgi 来运行它并获得正确的输出。我使用了 chmod +x math.cgi。但是当我看一下 http://127.0.1.1/cgi-bin/math.cgi< /a> 我收到内部服务器错误 500。

有谁知道我需要修复什么,例如 http://127.0.1.1/cgi-bin/math.cgi 也会给出正确的输出?

I decided to create a project which performs computation on a given input of the user.

I installed Python 2.7.2 and Numpy 1.6.1. I'm running Ubuntu 11.10 64bit with apache2 installed. My .cgi files are placed in /usr/lib/cgi-bin.
The first script math.cgi looks as follows:

#!/usr/bin/python

from numpy import *
from numpy.linalg import *
b = array([9,8])
a = array([[3,1], [1,2]])
x = solve(a,b)
print x

I can run it by typing python math.cgi in /usr/lib/cgi-bin and get the correct output. I used chmod +x math.cgi. But when I take a look at http://127.0.1.1/cgi-bin/math.cgi I get an Internal Server Error 500.

Does anyone have an idea what I need to fix, such that http://127.0.1.1/cgi-bin/math.cgi will also give the correct output?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还如梦归 2025-01-15 10:05:51

您必须先打印标题,例如此处所述

print "Content-Type: text/html"     # HTML is following
print                               # blank line, end of headers
print x # your output

You have to print the header first, such as described here

print "Content-Type: text/html"     # HTML is following
print                               # blank line, end of headers
print x # your output
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文