I'm trying to install PyMongo Python package with pip. It is required by Ansible mongodb_user module.
I'm installing pip and pymongo with following Ansible script:
- hosts: tag_Name_Development
become: true
remote_user: user
tasks:
- name: install python tools
yum: name={{ item }} state=latest
with_items:
- gcc
- python-devel
- python-setuptools
- python-pip
- name: install pymongo
pip: name=pymongo state=latest
- name: add admin user to mongo
mongodb_user:
login_port: 27017
database: admin
name: admin
password: "{{ mongodb.admin_pass }}"
roles: userAdminAnyDatabase
state: present
After successful installation of tools I get following Ansible error.
FAILED! => {"changed": false, "failed": true, "msg": "the python pymongo module is required"}
On server where pymongo
is installed I get
$ python -c "import pymongo"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pymongo
Other relevant info pip freeze
and pip list
$ python-pip freeze
backports.ssl-match-hostname==3.4.0.2
ordereddict==1.2
pymongo==3.3.0
$ python-pip list
backports.ssl-match-hostname (3.4.0.2)
ordereddict (1.2)
pip (6.1.1)
pymongo (3.3.0)
setuptools (12.2)
And loaded paths
$ python
Python 2.7.10 (default, Jul 20 2016, 20:53:27)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/local/lib64/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages', '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages', '/usr/lib64/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
There are many other questions related to this problem, but none of those have helped. I do not have bson
installed and I'm not using any virtual envs.