当我尝试在Python3.5.1中安装paramiko模块时,我得到了一个无效的语法,无法安装它

2024-04-25 11:51:22 发布

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

当我试图在命令提示符下向Python 3.5.1添加一个名为paramiko的模块以添加ssh通信功能时,我收到了以下错误消息,无法安装它

Traceback (most recent call last):
  File "C:\Users\tishi\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\tishi\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\tishi\AppData\Local\Programs\Python\Python35\lib\site_packages\pip\__main__.py", line 21, in <module
    from pip._internal.cli.main import main as _main
  File "C:\Users\tishi\AppData\Local\Programs\Python\Python35\lib\site_packages\pip\internal\cli\main.py", line 60
    sys.stderr.write(f "ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

对于安装方法,我输入了以下内容

py -m pip install paramiko

我希望你能帮我解决这个问题,谢谢


1条回答
网友
1楼 · 发布于 2024-04-25 11:51:22

如错误消息所示,字符串和变量编辑规范f“error:{exc}”是一个格式化的字符串文本,自Python 3.6以来一直支持该规范

您的3.5.1版本不支持它们,因此您可能会得到SyntaxError:无效语法

How to use f-strings (formatted string literals) in Python

Python 3.6 introduced the f-string (f-strings, format string, formatted string literal) mechanism, which makes it easier to write the redundant string method format().

Note that this is not available in versions prior to 3.5.

Formatting strings using formatted string literals (f-strings)

When formatting strings, formatted string literals (f-strings) are available since Python 3.6 as a more concise way to use the format method.

如果你仔细观察,问题似乎不是由帕拉米科引起的,而是皮普

另外,如果你看一下pip 20.3.4 - PyPI,看起来Python 2.7/3.5在这个版本之前是受支持的,就在最近(2021年1月23日),这两个版本都是在同一天发布的,21.0系列只支持Python 3.6和更高版本,20.3系列也支持Python 2.7/3.5。两人在同一天获释

Release history - pip - PyPI[enter link description here][1]

如果您的pip已经升级到21.x,那么无论您做什么,您都可能无法使用该模块,但是您可以尝试几种方法来降低pip版本号

重新安装pip本身,旧版本号高达20.3.4。 使用@metropolis引入的方法安装Python3.5的pip 创建一个新的Python 3.5.1环境,并在其中安装用于Python 3.5的pip

相关问题 更多 >