Python2.7 OS Centos7 64位中的CherryPy

2024-04-20 09:10:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在Centos7 64位中使用CherryPy做一些实用程序。你知道吗

在尝试运行最基本的CherryPy示例时,出现以下错误:

$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"

$ python --version
Python 2.7.5

$ pip show CherryPy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Name: CherryPy
Version: 17.4.1
Summary: Object-Oriented HTTP framework
Home-page: https://www.cherrypy.org
Author: CherryPy Team
Author-email: team@cherrypy.org
License: UNKNOWN
Location: /usr/lib64/python2.7/site-packages
Requires: more-itertools, contextlib2, cheroot, zc.lockfile, portend, six
Required-by:

$ cat example.py
# -*- coding: utf-8 -*-

import cherrypy

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

cherrypy.quickstart(HelloWorld())

$ python example.py
Traceback (most recent call last):
  File "example.py", line 3, in <module>
    import cherrypy
  File "/usr/lib64/python2.7/site-packages/cherrypy/__init__.py", line 73, in <module>
    from ._cptools import default_toolbox as tools, Tool
  File "/usr/lib64/python2.7/site-packages/cherrypy/_cptools.py", line 33, in <module>
    from cherrypy.lib import auth_basic, auth_digest
  File "/usr/lib64/python2.7/site-packages/cherrypy/lib/auth_digest.py", line 27, in <module>
    from six.moves.urllib.request import parse_http_list, parse_keqv_list
ImportError: cannot import name parse_http_list

Tags: infrompyimportauthexamplepackagesusr