我试图从python脚本启动一个ansible剧本,但出现以下错误:
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位置:
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模块吗?
非常感谢
发布于 2021-02-25 22:27:31
请忽略它。我发现我在服务器上安装了两个python版本: Python2.7和3.6。Python3.6目录没有安装该模块,因此我需要使用Python2.7启动该程序。
https://stackoverflow.com/questions/66366723
复制相似问题