首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Python API运行ansible-playbook

使用Python API运行ansible-playbook
EN

Stack Overflow用户
提问于 2021-02-25 18:26:04
回答 1查看 62关注 0票数 0

我试图从python脚本启动一个ansible剧本,但出现以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "py_runner.py", line 1, in <module>
    from ansible import context
ModuleNotFoundError: No module named 'ansible'

我正在使用我在这个链接Running ansible-playbook using Python API上找到的代码之一,这是我的ansible位置:

代码语言:javascript
复制
  ansible 2.8.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

你能帮我找出为什么我的pythom程序找不到ansible模块吗?

非常感谢

EN

回答 1

Stack Overflow用户

发布于 2021-02-25 22:27:31

请忽略它。我发现我在服务器上安装了两个python版本: Python2.7和3.6。Python3.6目录没有安装该模块,因此我需要使用Python2.7启动该程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66366723

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档