Ansible-builder – 语法错误:无效的语法

huangapple go评论113阅读模式
英文:

Ansible-builder - SyntaxError: invalid syntax

问题

我需要为AWX创建自定义镜像,以便可以将外部Python模块添加到我的Ansible Playbooks中。我安装了ansible-builder来执行此操作,但无论我尝试运行哪个命令,都会出现以下错误:

me@ansible:~$ ansible-builder --help
Traceback (most recent call last):
  File "/usr/local/bin/ansible-builder", line 7, in <module>
    from ansible_builder.cli import run
  File "/usr/local/lib/python3.5/dist-packages/ansible_builder/cli.py", line 104
    help=f'The name(s) for the container image being built (default: {constants.default_tag})')
                                                                                           ^
SyntaxError: invalid syntax

我是这样在Debian 9上安装它的:

pip install ansible-builder

我尝试使用pip和pip3、以及我的用户和root帐户安装它,但每次都遇到相同的错误。

英文:

I needed to create a custom image for AWX so that I can add external python modules to my ansible playbooks. I installed ansible-builder to do that but I'm getting the following error for any commands I try to run with ansible-builder :

me@ansible:~$ ansible-builder --help
Traceback (most recent call last):
  File &quot;/usr/local/bin/ansible-builder&quot;, line 7, in &lt;module&gt;
    from ansible_builder.cli import run
  File &quot;/usr/local/lib/python3.5/dist-packages/ansible_builder/cli.py&quot;, line 104
    help=f&#39;The name(s) for the container image being built (default: {constants.default_tag})&#39;)
                                                                                             ^
SyntaxError: invalid syntax

I installed it on debian 9 like so :

pip install ansible-builder

I tried to install it with pip and pip3, my user and root but I'm getting the same error everytime.

答案1

得分: 0

f-strings 只在 Python 3.6 及更高版本中可用(PEP-498),而根据您的错误信息,您正在使用 Python 3.5(来自您的回溯信息:"/usr/local/lib/python3.5/dist-packages/ansible_builder/cli.py"),因此存在版本不兼容性。

您需要升级到更高版本的 Python。即使是最早的 ansible-builder 发布版 在 Pypi 上 也要求使用 Python >=3.6, <4.0

英文:

f-strings only became available in python 3.6 (PEP-498 and you are using python 3.5 (from your traceback: &quot;/usr/local/lib/python3.5/dist-packages/ansible_builder/cli.py&quot;), so you have a version incompatibility.

You will need to update to a more recent python version. Even the oldest ansible-builder release on Pypi requires Python &gt;=3.6, &lt;4.0

huangapple
  • 本文由 发表于 2023年5月26日 15:08:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76338398.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定