端口 80 上的套接字错误
Socketerror on port 80
我在使用 PyInstaller 创建工作可执行文件时遇到问题。我已经能够使用 Python 和 Bottle 成功创建一个简单的 Web 服务器 - 但是当我使用 PyInstaller 创建我的可执行文件并单击它时 - 我得到以下输出:
Alans-MBP:~ alanscarpa$ /Users/alanscarpa/Desktop/testSite/dist/testing ; exit;
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:80/
Hit Ctrl-C to quit.
Traceback (most recent call last):
File "<string>", line 10, in <module>
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/bottle", line 3093, in run
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/bottle", line 2692, in run
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/wsgiref.simple_server", line 151, in make_server
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/SocketServer", line 420, in __init__
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/wsgiref.simple_server", line 48, in server_bind
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/BaseHTTPServer", line 108, in server_bind
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/SocketServer", line 434, in server_bind
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/socket", line 224, in meth
socket.error: [Errno 13] Permission denied
logout
[Process completed]
前 3 行是完美的 - 如果工作正常,它应该是这样的:
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:80/
Hit Ctrl-C to quit.
但是之后的一切都把我的程序搞砸了!
这是我的 Python 文件,名为 testing.py
#!/usr/bin/python
from bottle import route, run, template
@route('/testing')
def index():
return 'Hello..testing'
run(host='0.0.0.0', port=80, debug=True)
当我访问 mylocalip/testing - 我的网页不可用。但是如果我打开终端并写: sudo /path/to/testing - 它工作得很好。 (我显然希望能够将可执行文件发送给某人,他们只需单击它即可 运行,而不必使用终端)。
有什么建议吗?
编辑:我将端口更改为 8080,它可以正常工作!有人知道为什么吗?
在大多数系统(至少 BSD、OS X 和 Linux)上,如果没有 root 权限,您将无法监听低于 1024 的端口。
我在使用 PyInstaller 创建工作可执行文件时遇到问题。我已经能够使用 Python 和 Bottle 成功创建一个简单的 Web 服务器 - 但是当我使用 PyInstaller 创建我的可执行文件并单击它时 - 我得到以下输出:
Alans-MBP:~ alanscarpa$ /Users/alanscarpa/Desktop/testSite/dist/testing ; exit;
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:80/
Hit Ctrl-C to quit.
Traceback (most recent call last):
File "<string>", line 10, in <module>
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/bottle", line 3093, in run
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/bottle", line 2692, in run
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/wsgiref.simple_server", line 151, in make_server
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/SocketServer", line 420, in __init__
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/wsgiref.simple_server", line 48, in server_bind
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/BaseHTTPServer", line 108, in server_bind
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/SocketServer", line 434, in server_bind
File "/Users/alanscarpa/Desktop/testSite/build/testing/out00-PYZ.pyz/socket", line 224, in meth
socket.error: [Errno 13] Permission denied
logout
[Process completed]
前 3 行是完美的 - 如果工作正常,它应该是这样的:
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:80/
Hit Ctrl-C to quit.
但是之后的一切都把我的程序搞砸了!
这是我的 Python 文件,名为 testing.py
#!/usr/bin/python
from bottle import route, run, template
@route('/testing')
def index():
return 'Hello..testing'
run(host='0.0.0.0', port=80, debug=True)
当我访问 mylocalip/testing - 我的网页不可用。但是如果我打开终端并写: sudo /path/to/testing - 它工作得很好。 (我显然希望能够将可执行文件发送给某人,他们只需单击它即可 运行,而不必使用终端)。
有什么建议吗?
编辑:我将端口更改为 8080,它可以正常工作!有人知道为什么吗?
在大多数系统(至少 BSD、OS X 和 Linux)上,如果没有 root 权限,您将无法监听低于 1024 的端口。