1

我正在尝试从我的 requirements.txt 安装更新:

pip install -r requirements.txt

但是当安装到 cheetah 时,它会打印出这个错误:

I'm trying to run some updates require by pycharm, so for the update of cheetah I got this error:
Collecting Cheetah==2.4.4 (from -r requirements.txt (line 6))
  Using cached https://files.pythonhosted.org/packages/cd/b0/c2d700252fc251e91c08639ff41a8a5203b627f4e0a2ae18a6b662ab32ea/Cheetah-2.4.4.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-rnxaujfa/Cheetah/setup.py", line 10, in <module>
        import SetupTools
      File "/tmp/pip-build-rnxaujfa/Cheetah/SetupTools.py", line 50
        except DistutilsPlatformError, x:
                                     ^
    SyntaxError: invalid syntax
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-rnxaujfa/Cheetah/

请帮我 !

4

1 回答 1

2

报错说明代码是用Python 2写的,可能依赖Cheetah的库也是用Python 2写的,建议你创建anaconda环境,安装Python 2.7代替。

如果你坚持使用 Python 3,Cheetah3 已经发布(https://cheetahtemplate.org/)你应该在 requirements.txt 文件中更新 Cheetah 的版本号,比如 Cheetah==3.2.6。您可能还需要使用 2to3 来升级代码。

于 2020-10-13T14:11:37.957 回答