当前位置:编程学习 > 网站相关 >>

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

错误信息如下:


[plain]
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' 

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行为如下内容:

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

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

补充:Web开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,