CherryPy AttributeError:'Module_six_moves_urllib_parse'对象没有属性'unquote _to_bytes'

时间:2019-02-04 12:42:15

标签: python cherrypy

我正在尝试使用cherryPy,但是在访问网页时显示以下错误:AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'unquote_to_bytes'。我已经检查了模块six.moves urllib_parse具有名为unquote_to_bytes的属性,但仍然Cherrypy显示此错误。服务器正常启动,但是仅在通过键入URL访问网页时才会显示此错误。下面是从仅使用IP和端口号修改的cherrypy基本教程中复制的代码:

import cherrypy
import globals


class HelloWorld(object):
   @cherrypy.expose
   def index(self):
     return "Hello World!"


cherrypy.config.update({'server.socket_host': "192.168.10.11",
                    'server.socket_port': 8088,
                    })
cherrypy.quickstart(HelloWorld())

这是实际的回溯:

[04/Feb/2019:20:26:23] ENGINE
AttributeError("'Module_six_moves_urllib_parse' object has no attribute 'unquote_to_bytes'",)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/cheroot/server.py", line 1242, in communicate req.parse_request()
File "/usr/local/lib/python3.4/dist-packages/cheroot/server.py", line  712, in parse_request
success = self.read_request_line()
File "/usr/local/lib/python3.4/dist-packages/cheroot/server.py", line  912, in read_request_line for x in QUOTED_SLASH_REGEX.split(path)
File "/usr/local/lib/python3.4/dist-packages/cheroot/server.py", line  912, in <listcomp> for x in QUOTED_SLASH_REGEX.split(path)AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'unquote
_to_bytes'

1 个答案:

答案 0 :(得分:0)

我遇到了类似的错误,并且注意到当前的CherryPy和cheroot版本确实起着重要作用。

我做了如下修复:

pip uninstall CherryPy

pip install --force-reinstall CherryPy==18.1.0

pip uninstall cheroot

pip install --force-reinstall cheroot==6.5.4

我希望这也对您有用。