1

我需要运行需要 autopy 的代码(对于 python 2.7)

蟒蛇 2.7

setuptools-rust 0.11.4

尸检4.0.0

C:\pip install autopy
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. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting autopy
  Using cached https://files.pythonhosted.org/packages/3d/3e/e589bfe03c7ee1c3d832dda10b908557f25a09d66acfc8fc7d982ee23d1a/autopy-4.0.0.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\unitedsalvatore\appdata\local\python\python27\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\united~1\\appdata\\local\\temp\\pip-install-j55cvn\\autopy\\setup.py'"'"'; __file__='"'"'c:\\users\\united~1\\appdata\\local\\temp\\pip-install-j55cvn\\autopy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: c:\users\united~1\appdata\local\temp\pip-install-j55cvn\autopy\
    Complete output (10 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\united~1\appdata\local\temp\pip-install-j55cvn\autopy\setup.py", line 8, in <module>
        from setuptools_rust import Binding, RustExtension
      File "c:\users\unitedsalvatore\appdata\local\python\python27\lib\site-packages\setuptools_rust\__init__.py", line 8, in <module>
        from .tomlgen import tomlgen_rust, find_rust_extensions
      File "c:\users\unitedsalvatore\appdata\local\python\python27\lib\site-packages\setuptools_rust\tomlgen.py", line 191
        yield dep, toml.loads(f"{dep} = {options}")[dep]
                                                 ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 20.3.4 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

为什么我会看到此错误?我是python的新手

4

1 回答 1

1

安装代码使用格式字符串(f-strings),仅 Python 3.6+ 支持。由于您使用的是 Python 2.7,它无法识别这一点并引发语法错误。要解决这个问题,您需要至少升级到 Python 3.6 或更高版本。

有关更多信息,Real Python在这里有一篇很好的文章。

于 2021-06-29T00:21:00.377 回答