我有一个 bash 脚本,它有助于建立一个本地SimpleHTTPServer
.
python -m SimpleHTTPServer 8080
我把它放在我的项目文件夹中。当我使用以下方法运行程序时:
subprocess.call('./setup.sh')
出现一条错误消息:
Traceback (most recent call last):
File "test.py", line 2, in <module>
subprocess.call('./setup.sh')
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
我在终端重试了这个
localhost:Desktop XXXX$ sh setup.sh
Serving HTTP on 0.0.0.0 port 8080 ...
它工作正常。我记得有几次终端弹出一个窗口询问我关于python的权限关于防火墙相关的事情,我允许了。你能帮助我吗?