# Problem to install or detect if passlib module is installed

**URL:** <https://forum.ansible.com/t/problem-to-install-or-detect-if-passlib-module-is-installed/43202>\
**Category:** Get Help\
**Created:** [June 6, 2025, 7:42am UTC](https://forum.ansible.com/t/problem-to-install-or-detect-if-passlib-module-is-installed/43202 "2025-06-06T07:42:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcoussi](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mcoussi/32/8056_2.png) [@mcoussi](https://forum.ansible.com/u/mcoussi)\
**Post date:** [June 6, 2025, 7:42am UTC](https://forum.ansible.com/t/problem-to-install-or-detect-if-passlib-module-is-installed/43202/1 "2025-06-06T07:42:27Z")

</div>

Hi,

I installed passlib python like below :

```auto
- pip:
    name: "passlib"
  environment:
    http_proxy: "{{ proxy.url }}:{{ proxy.port }}"
    https_proxy: "{{ proxy.url }}:{{ proxy.port }}"

```

It works since many time.

I’ve a playbook to deploy configuration on DBServer, and execute the task above.

But since yesterday on some DBServer, i’ve got this error.

```auto
{
  "exception": "Traceback (most recent call last):\n File \"/tmp/ansible_pip_payload_yosxm2nv/ansible_pip_payload.zip/ansible/modules/pip.py\", line 284, in <module>\n from packaging.requirements import Requirement as parse_requirement\nModuleNotFoundError: No module named 'packaging'\n",
  "msg": "Failed to import the required Python library (packaging) on XXXXXXXXXgm's Python /usr/bin/python3.12. Please read the module documentation and install it 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",
  "invocation": {
    "module_args": {
      "name": [
        "passlib"
      ],
      "state": "present",
      "virtualenv_site_packages": false,
      "virtualenv_command": "virtualenv",
      "editable": false,
      "version": null,
      "requirements": null,
      "virtualenv": null,
      "virtualenv_python": null,
      "extra_args": null,
      "chdir": null,
      "executable": null,
      "umask": null
    }
  },
  "_ansible_no_log": false,
  "attempts": 5,
  "changed": false,
  "item": "passlib",
  "ansible_loop_var": "item",
  "_ansible_item_label": "passlib"
}

```

This module is already installed on the DBServer

```auto
[root@XXXXXXXXX log]# pip3 install passlib
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Requirement already satisfied: passlib in /usr/local/lib/python3.6/site-packages

```

Do you know what’s wrong with my configuration please ?

Thanks for your help,

Matt

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [June 6, 2025, 10:15am UTC](https://forum.ansible.com/t/problem-to-install-or-detect-if-passlib-module-is-installed/43202/2 "2025-06-06T10:15:13Z")

</div>

> “msg”: “Failed to import the required Python library (packaging) on XXXXXXXXXgm’s Python /usr/bin/python3.12. Please read the module documentation and install it 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”,

has a different path / python interpreter than

> Requirement already satisfied: passlib in /usr/local/lib/python3.6/site-packages

(ansible is failing to find the module in `/usr/bin/python3.12` while root is confirming its installed in `/usr/local/lib/python3.6/site-packages`)

---

<div class="post-metadata">

**Author:** ![mcoussi](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mcoussi/32/8056_2.png) [@mcoussi](https://forum.ansible.com/u/mcoussi)\
**Post date:** [June 6, 2025, 11:43am UTC](https://forum.ansible.com/t/problem-to-install-or-detect-if-passlib-module-is-installed/43202/3 "2025-06-06T11:43:40Z")

</div>

Hi @Lyle_McKarns,

Thanks for your reply.

I found this topic :

> [@Ansible python interpreter](https://forum.ansible.com/t/ansible-python-interpreter/8500/5):
>
> Hi. You can fix it by installing the “required python packages” in your venv with pip. --- - 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 pyt…

When i set the var [ansible\_python\_interpreter] in my playbook :

```auto
  vars:
     ansible_python_interpreter: "/usr/bin/python3"

```

The playbook works.

I found the difference between why it works on a DBServer and not working on other DBserver.  
It’s what you mentionned with [`/usr/bin/python3.12`]

On working DBServer, the python3.12 is not installed :

```auto
[root@OKDBSERVER check_mk]# ll /usr/bin/python3*
lrwxrwxrwx 1 root root 25 22 juin 2022 /usr/bin/python3 -> /etc/alternatives/python3
lrwxrwxrwx 1 root root 31 12 déc. 14:55 /usr/bin/python3.6 -> /usr/libexec/platform-python3.6
lrwxrwxrwx 1 root root 17 12 déc. 14:55 /usr/bin/python3.6-config -> python3.6m-config
lrwxrwxrwx 1 root root 32 12 déc. 14:55 /usr/bin/python3.6m -> /usr/libexec/platform-python3.6m
lrwxrwxrwx 1 root root 39 12 déc. 14:55 /usr/bin/python3.6m-config -> /usr/libexec/platform-python3.6m-config
lrwxrwxrwx 1 root root 46 12 déc. 14:55 /usr/bin/python3.6m-x86_64-config -> /usr/libexec/platform-python3.6m-x86_64-config
lrwxrwxrwx 1 root root 32 21 nov. 2023 /usr/bin/python3-config -> /etc/alternatives/python3-config

```

On not working DBServer python3.12 is installed :

```auto
[root@KODBSERVER etc]# ll /usr/bin/python3*
lrwxrwxrwx 1 root root 25 20 juin 2024 /usr/bin/python3 -> /etc/alternatives/python3
-rwxr-xr-x 1 root root 7752 12 déc. 14:05 /usr/bin/python3.12
lrwxrwxrwx 1 root root 31 12 déc. 14:55 /usr/bin/python3.6 -> /usr/libexec/platform-python3.6
lrwxrwxrwx 1 root root 17 12 déc. 14:55 /usr/bin/python3.6-config -> python3.6m-config
lrwxrwxrwx 1 root root 32 12 déc. 14:55 /usr/bin/python3.6m -> /usr/libexec/platform-python3.6m
lrwxrwxrwx 1 root root 39 12 déc. 14:55 /usr/bin/python3.6m-config -> /usr/libexec/platform-python3.6m-config
lrwxrwxrwx 1 root root 46 12 déc. 14:55 /usr/bin/python3.6m-x86_64-config -> /usr/libexec/platform-python3.6m-x86_64-config
lrwxrwxrwx 1 root root 32 20 juin 2024 /usr/bin/python3-config -> /etc/alternatives/python3-config

```

The alternative for python3 pointed target [/usr/bin/python3.6] :

```auto
[root@KODBSERVER etc]# ll /etc/alternatives/python3
lrwxrwxrwx 1 root root 18 20 juin 2024 /etc/alternatives/python3 -> /usr/bin/python3.6

```

I don’t know why python3.12 is installed on some DBServer…

Matt
