Python 2.7 在OS X上拒绝Python CGIHTTP服务器访问

Python 2.7 在OS X上拒绝Python CGIHTTP服务器访问,python-2.7,permissions,osx-mountain-lion,cgihttpserver,Python 2.7,Permissions,Osx Mountain Lion,Cgihttpserver,我在试图从浏览器触发CGI中的Python脚本时出现此错误 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/CGIHTTPServer.py", line 251, in run_cgi os.execve(scriptfile, args, env) OSError: [Errno 13] Permission denie

我在试图从浏览器触发CGI中的Python脚本时出现此错误

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/CGIHTTPServer.py", line 251, in run_cgi
    os.execve(scriptfile, args, env)
OSError: [Errno 13] Permission denied
1.0.0.127.in-addr.arpa - - [20/Apr/2013 14:51:16] CGI script exit status 0x7f00
我没有以root用户身份运行主进程(
$python-32main.py

似乎对我不起作用


使脚本可执行也不起作用(
$chmod+x index.py
-rwxr-xr-x
)。

终于让它起作用了。这是基本脚本

index.py

#!/usr/bin/env python
import cgi
print 'Content-Type: text/html\n\n'
print ''
print 'test'
要求

  • 文件需要是可执行的<代码>$chmod+x index.py
  • 该文件需要有
    #/usr/bin/env python
希望将来能对别人有所帮助