Python PermissionError: [Errno 13] 权限被拒绝 Flask.run()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38298652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PermissionError: [Errno 13] Permission denied Flask.run()
提问by c3cris
I am running MacOS X with python 3. The folder and files have 755 but I have also tested it in 777 with no luck. My question is if I have the right permissions why does it not let me run without sudo. Or are my settings incorrect?
我正在使用 python 3 运行 MacOS X。文件夹和文件有 755,但我也在 777 中对其进行了测试,但没有运气。我的问题是,如果我拥有正确的权限,为什么它不让我在没有 sudo 的情况下运行。还是我的设置不正确?
cris-mbp:ProjectFolder cris$ python3 zbo.py
Traceback (most recent call last):
File "zbo.py", line 9, in <module>
app.run(host="127.0.0.1",port=81,debug=True)
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 843, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python3.5/site-packages/werkzeug/serving.py", line 677, in run_simple
s.bind((hostname, port))
PermissionError: [Errno 13] Permission denied
cris-mbp:ProjectFolder cris$ sudo python3 zbo.py
* Running on http://127.0.0.1:81/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 106-133-233
回答by Matt Healy
You're trying to run the app on a privileged port(81) - if you use a higher port such as 5000 you won't need sudo privileges.
您正在尝试在特权端口(81)上运行应用程序- 如果您使用更高的端口,例如 5000,则不需要 sudo 权限。
回答by Jonathon Reinhart
The "permission denied" error is occurring on the bind
call; this has nothing to do with directory permissions.
bind
通话中出现“权限被拒绝”错误;这与目录权限无关。
You're attempting to bind to port 81 (an odd choice), which is a privileged port (one that is less than 1024). This means you need to run it as root.
您正在尝试绑定到端口 81(一个奇怪的选择),这是一个特权端口(小于 1024 的端口)。这意味着您需要以 root 身份运行它。
回答by harish
go to c:\python27\ directory and rigtlcick python.exe and tab to compaitbility and select the admin privilege option and apply the changes. Now you issue the command it allows to create the socket connection.after that run script using python
转到 c:\python27\ 目录和 rigtlcick python.exe 和选项卡以兼容并选择管理员权限选项并应用更改。现在您发出它允许创建套接字连接的命令。然后使用 python 运行脚本