英文:
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 "/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
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: "/usr/local/lib/python3.5/dist-packages/ansible_builder/cli.py"
), 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 >=3.6, <4.0
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论