# Ansible python interpreter

**URL:** <https://forum.ansible.com/t/ansible-python-interpreter/8500>\
**Category:** Get Help\
**Tags:** git, python, ansible, ubuntu, galaxy-ng\
**Created:** [September 13, 2024, 7:00pm UTC](https://forum.ansible.com/t/ansible-python-interpreter/8500 "2024-09-13T19:00:13Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 18, 2024, 7:17am UTC](https://forum.ansible.com/t/ansible-python-interpreter/8500/5 "2024-09-18T07:17:09Z")

</div>

Hi. You can fix it by installing the “required python packages” in your venv with pip.

```yaml
---
- name: Install SQL scripts on Private PostgreSQL Instance
  hosts: localhost
  gather_facts: true
  become: true

  tasks:
    - name: Install required python packages
      ansible.builtin.pip:
       name:
         - libpq-dev
         - python3-psycopg2
       virtualenv: "{{ ansible_facts['env']['VIRTUAL_ENV'] }}"
       state: present

```

The other option is to set the python interpreter to your OS python interpreter, as pointed out by @felixfontein:

```yaml
---
- name: Install SQL scripts on Private PostgreSQL Instance
  hosts: localhost
  gather_facts: false
  become: true
  vars:
     ansible_python_interpreter: "/usr/bin/python3"

```

---

_[View the full topic](https://forum.ansible.com/t/ansible-python-interpreter/8500)._
