python3的可见模块问题



下午好,我有一个pymongo模块,我通过pip3安装,现在我正试图使用它

- name: Create role for pbm
community.mongodb.mongodb_shell:
login_host: 10.0.44.40
eval: 'db.getSiblingDB ("admin"). createRole ({"role": "pbmAnyAction", "privileges": [{"resource": {"anyResource": true}, "actions": ["anyAction"] }], "roles": []}); '
vars:
ansible_python_interpreter: / usr / bin / python3
ignore_errors: yes
when: groups.mongodb.index (inventory_hostname) == 0

在我的本地迁移虚拟机上一切正常,但是当我在生产虚拟机上运行它时,出现了一个错误

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pymongo.errors
fatal: [mongodb-01]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (pymongo) on superproduction-mongo-01's Python / usr / bin / python. Please read module documentation and install 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 "}

运行版和生产版操作系统版本相同(centos 7)

python3版本输出并导入pymongo。生产虚拟机错误

python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo.errors
>>> 

from vagrant vm

python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo.errors
>>>

你可以看到输出相同的

即使我什么都没做

最新更新