Python Ansible找不到pexpect,但它已安装

Python Ansible找不到pexpect,但它已安装,python,ansible,centos8,Python,Ansible,Centos8,朋友们 我试图在CentOS 8主机上使用ansible.builtin.expect模块执行任务,出现以下错误: An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'pexpect'fatal: [gblix]: FAILED! => {"changed"

朋友们

我试图在CentOS 8主机上使用ansible.builtin.expect模块执行任务,出现以下错误:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError:
No module named 'pexpect'fatal: [gblix]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library 
(pexpect) on centos's Python /usr/libexec/platform-python. Please read the module documentation and install it in the 
appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter,
please consult the documentation on ansible_python_interpreter"}
我运行了pip3安装pexexpect,它已安装:

Requirement already satisfied: pexpect in /home/marcelo/.local/lib/python3.6/site-packages
Requirement already satisfied: ptyprogress>=0.5 in /home/marcelo/.local/lib/python3.6/site-packages
(from pexpect)
然后我运行了ansible gblix-m安装程序| grep ansible_python_版本,输出为ansible_python_版本:3.6.8

我还检查了my/usr/bin目录,输出如下所示:

[marcelo@centos bin]$ ls -l | grep python
lrwxrwxrwx. 1 root root       9 Aug 31  2020 python2 -> python2.7
-rwxr-xr-x. 1 root root    8224 Aug 31  2020 python2.7
lrwxrwxrwx. 1 root root      25 May 16 14:52 python3 -> /etc/alternatives/python3
lrwxrwxrwx. 1 root root      31 Nov  4  2020 python3.6 -> /usr/libexec/platform-python3.6
lrwxrwxrwx. 1 root root      32 Nov  4  2020 python3.6m -> /usr/libexec/platform-python3.6m
lrwxrwxrwx. 1 root root      24 Feb 23 19:27 unversioned-python -> /etc/alternatives/python

如果我没有记错的话,pexpect已经安装,ansible正在使用正确的python解释器。你知道我该怎么解决这个问题吗?我有很多信息,但我不知道如何解释它来找到解决方案?

ansible中缺少python依赖项的一个常见解决方案是将需求包含在剧本中,以确保它不仅当前可用,而且将来也可用

-名称:确保在playbook python中安装了pexpect pip: 姓名:pexpect 国家:现在 -name:现在您可以在所有情况下使用该依赖关系 期望:。。。
这是一个如此常见的错误,我希望它有一个常见问题;如果您不能运行/usr/libexec/platformpython-c import-pexpect,那么ansible当然也不能。你的问题完全没有任何剧本片段,但解决这一问题的最常见的办法是按照剧本礼貌地要求设置ansible_python_解释器,或者在剧本中加入-pip:{name:pexpect,state:present},以使未来的机器保持正确的状态感谢帮助,@mdaniel!一般来说,我对IT界还是新手,尤其是ansible。有些事情对更有经验的人来说似乎很明显,但对我来说,有时却不那么明显。我尝试了你的建议——pip:{name:pexpect,state:present}——这足以解决我的问题。谢谢!如果你愿意,发表你的评论作为我接受它的答案。