web.py 启动时候出现AttributeError: 'module' object has no attribute 'inet_pton'错误

错误信息如下:

Traceback (most recent call last):
  File "webpy.py", line 84, in <module>
    app.run()
  File "D:\Python27\lib\site-packages\web\application.py", line 313, in run
    return wsgi.runwsgi(self.wsgifunc(*middleware))
  File "D:\Python27\lib\site-packages\web\wsgi.py", line 55, in runwsgi
    server_addr = validip(listget(sys.argv, 1, ''))
  File "D:\Python27\lib\site-packages\web\net.py", line 108, in validip
    if validip6addr(ip): return (ip,port)
  File "D:\Python27\lib\site-packages\web\net.py", line 33, in validip6addr
    socket.inet_pton(socket.AF_INET6, address)
AttributeError: 'module' object has no attribute 'inet_pton'

解决方法,修改Python安装目录下Lib\site-packages\web\net.py文件的第32到第35行为如下内容:

    try:
        socket.inet_pton(socket.AF_INET6, address)
    except:
        return False

参考: https://github.com/webpy/webpy/pull/195#issuecomment-19143945

你可能感兴趣的:(python,web.py)