# psycog2 is installed but postgresql\_user gives error that psycog2 is required

**URL:** <https://forum.ansible.com/t/psycog2-is-installed-but-postgresql-user-gives-error-that-psycog2-is-required/26928>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [March 7, 2018, 10:00pm UTC](https://forum.ansible.com/t/psycog2-is-installed-but-postgresql-user-gives-error-that-psycog2-is-required/26928 "2018-03-07T22:00:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gearoidibm](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@gearoidibm](https://forum.ansible.com/u/gearoidibm)\
**Post date:** [March 7, 2018, 10:00pm UTC](https://forum.ansible.com/t/psycog2-is-installed-but-postgresql-user-gives-error-that-psycog2-is-required/26928/1 "2018-03-07T22:00:17Z")

</div>

psycog2 has beeen installed using ansible pip module.

The postgresql\_user module fails with a message saying psycog2 is required.

pip list shows that psycog2 is installed on the managed system.  
ansible 2.4.3, python 2.7.10  
managed system is rhel 7.4

Have I missed something ?

---

<div class="post-metadata">

**Author:** ![gearoidibm](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@gearoidibm](https://forum.ansible.com/u/gearoidibm)\
**Post date:** [March 7, 2018, 10:44pm UTC](https://forum.ansible.com/t/psycog2-is-installed-but-postgresql-user-gives-error-that-psycog2-is-required/26928/2 "2018-03-07T22:44:14Z")

</div>

I found that with /usr/bin/python I cannot import psycopg2, but with /usr/local/bin/python I can. Guess there’s two python envs on my managed host.

---

<div class="post-metadata">

**Author:** ![gearoidibm](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@gearoidibm](https://forum.ansible.com/u/gearoidibm)\
**Post date:** [March 7, 2018, 10:45pm UTC](https://forum.ansible.com/t/psycog2-is-installed-but-postgresql-user-gives-error-that-psycog2-is-required/26928/3 "2018-03-07T22:45:30Z")

</div>

solved by setting  
ansible\_python\_interpreter: /usr/local/bin/python
