我们需要为 cgi 安装 library/package 到 运行 Python 脚本(在 WAMP 上)吗?还是自动可用(在 WAMP 服务器中)?

Do we need to install library/package for cgi to run Python scripts (on WAMP)? Or is it available automatically (in WAMP server)?

我是 运行ning Python 3.5,我尝试使用 pip 安装 cgi,它给了我以下消息:

Could not find a version that satisfies the requirement cgi (from versions:)
No matching distribution found for cgi

我想在我的浏览器上 运行 Python 脚本(本地,使用 WAMP 服务器),通过一些研究我了解到我们需要使用 cgi 来实现相同的目的。我想知道是否需要安装cgi包,或者直接可用(安装Python或安装WAMP服务器时),所以我们应该只配置(相应文件夹中的httpd文件) ) WAMP 服务器添加以下代码:

AddHandler cgi-script .cgi .py
Options Indexes FollowSymLinks ExecCGI

另外,我们是否可以将 Python 脚本文件放在 cgi-bin 文件夹(如果可用)中以便执行它们?

对于 CGI,您实际上不需要任何库(尽管 cgi from standard library is helpful) but I would strongly recommend to use WSGI as not only debugging is much easier with it. There is a WSGI as CGI adapter in the standard library but you can also use mod_wsgi 以获得更好的性能。

有像 bottle 这样的微框架,它们使构建站点变得更加容易,并且它们与 WSGI(因此也是 CGI)一起工作。