gpt4 book ai didi

python-2.7 - 错误 : [errno 13] Permission denied - What permissions does bottle py require?

转载 作者:行者123 更新时间:2023-12-02 04:54:55 26 4
gpt4 key购买 nike

我正在尝试运行 bottle py 但出现此错误:

Traceback (most recent call last):
File "/home/pi/Desktop/gggg.py", line 176, in <module>
run(host='somehost', port=81)
File "/usr/lib/python2.7/dist-packages/bottle.py", line 2426, in run
server.run(app)
File "/usr/lib/python2.7/dist-packages/bottle.py", line 2123, in run
srv = make_server(self.host, self.port, handler, **self.options)
File "/usr/lib/python2.7/wsgiref/simple_server.py", line 144, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python2.7/SocketServer.py", line 419, in __init__
self.server_bind()
File "/usr/lib/python2.7/wsgiref/simple_server.py", line 48, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.7/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 13] Permission denied
>>>

我以“pi”身份登录。以 root 用户身份登录可以解决问题。我的问题是 bottle py 和 python 需要什么权限运行(哪些文件夹和什么权限)?

编辑:

不确定这是否重要,但我的 python 文件在桌面目录中。我还将文件夹/子文件夹的权限设置为所有人读写。

最佳答案

1) 如果您计划在生产环境中运行它,则不应使用 Bottle 的内置网络服务器。您应该使用 Apache、nginx 等。来自 Bottle docs :

The built-in default server is based on wsgiref WSGIServer. This non-threading HTTP server is perfectly fine for development and early production, but may become a performance bottleneck when server load increases. There are three ways to eliminate this bottleneck:

  • Use a different server that is either multi-threaded or asynchronous.
  • Start multiple server processes and spread the load with a load-balancer.
  • Do both.

2) [如您所知,]您必须是 root 才能绑定(bind)到端口 80;没有办法解决这个问题。您是否考虑过使用 sudo

sudo /home/pi/Desktop/gggg.py

您可以配置 sudoers 以安全地允许用户“pi”仅执行 gggg.py(或您最终将用于生产的任何网络服务器)。

关于python-2.7 - 错误 : [errno 13] Permission denied - What permissions does bottle py require?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18152026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com