我試圖安裝PyMongo Python包與pip。它需要Ansible mongodb_user module。ImportError:沒有名爲pymongo的模塊
我安裝點子並與以下Ansible腳本pymongo:
- 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
成功安裝的我獲得以下Ansible錯誤的工具後。在安裝pymongo
FAILED! => {"changed": false, "failed": true, "msg": "the python pymongo module is required"}
在服務器上,我得到
$ python -c "import pymongo"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pymongo
其他相關信息pip freeze
和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)
,並加載路徑
$ 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']
還有很多其他問題與這個問題有關,但沒有一個幫助。我沒有安裝bson
,我沒有使用任何虛擬環境。