# Ansible pylibssh import error

**URL:** <https://forum.ansible.com/t/ansible-pylibssh-import-error/6092>\
**Category:** Get Help\
**Tags:** rhel\
**Created:** [May 30, 2024, 10:51pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092 "2024-05-30T22:51:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johntxjw](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/johntxjw/32/3520_2.png) [@johntxjw](https://forum.ansible.com/u/johntxjw)\
**Post date:** [May 30, 2024, 10:51pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/1 "2024-05-30T22:51:44Z")

</div>

RHEL 8.10  
ansible core 2.16.7  
python version 3.12.1

I’m getting a error on every play I try to run, not really sure what happened since I’m still new to linux and ansible.

Error:  
FAILED! =\> {“changed”: false, “msg”: “Failed to import the required Python library (ansible-pylibssh) on “server” 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”}

I tried installing pylibssh in appropriate location but I get the following error:

![image](https://us1.discourse-cdn.com/ansible/original/2X/6/6e9464a06793dc6b7c7fa9b4bf4d6d2f04ed3b1d.png)

Not really sure what to do now. ☹

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [May 31, 2024, 7:30am UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/2 "2024-05-31T07:30:23Z")

</div>

Hi  
I assume you did the following to install pylibssh on your RHEL server ? `pip3 install ansible-pylibssh` ?  
If yes, you can check the path where it is installed with ` pip3 show ansible-pylibssh`

And then, compare if you ansible configuration know this location with : `ansible --version` at line `ansible python module location`

Maybe your module is properly installed but somewhere ansible isn’t aware of.

---

<div class="post-metadata">

**Author:** ![johntxjw](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/johntxjw/32/3520_2.png) [@johntxjw](https://forum.ansible.com/u/johntxjw)\
**Post date:** [June 3, 2024, 8:18pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/3 "2024-06-03T20:18:35Z")

</div>

cmd “pip3 show ansible-pylibssh” points to /.local/lib/python3.6/site-packages

I’m not really sure how to troubleshoot this issue

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [June 4, 2024, 8:57am UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/4 "2024-06-04T08:57:55Z")

</div>

Ok and what does ansible --version show about python modules ?

---

<div class="post-metadata">

**Author:** ![johntxjw](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/johntxjw/32/3520_2.png) [@johntxjw](https://forum.ansible.com/u/johntxjw)\
**Post date:** [June 4, 2024, 3:33pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/5 "2024-06-04T15:33:40Z")

</div>

ansible python module location = ./.local/lib/python3.12/site-packages/ansible

its pointing to a different location

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [June 5, 2024, 12:18pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/6 "2024-06-05T12:18:14Z")

</div>

Ok so it means your module is properly installed but ansible isn’t aware of where it is installed.  
When you’re installing your module, you’re doing it with the same account that has been used to install ansible?

If no, try to switch your user and re-install pylibssh

Else, you can specify the folder where pip install your package, i.e :

```auto
pip install --target ./.local/lib/python3.12/site-packages/ansible ansible-pylibssh

```

---

<div class="post-metadata">

**Author:** ![Gnonthgol](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@Gnonthgol](https://forum.ansible.com/u/Gnonthgol)\
**Post date:** [June 5, 2024, 1:33pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/7 "2024-06-05T13:33:21Z")

</div>

It looks as though you have both python 3.6 and python 3.12 installed. This is perfectly fine as you can have both installed at the same time. But they do not share modules. It appears like ansible is using python 3.12 while pip3 is using python 3.6. This is why ansible can not find the module you installed using pip3. Try installing the modules you need with pip3.12 if you have it. You can also use “python3.12 -m pip” to run pip with python 3.12.

---

<div class="post-metadata">

**Author:** ![Bryan\_Yingst](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bryan_yingst/32/3883_2.png) [@Bryan\_Yingst](https://forum.ansible.com/u/Bryan_Yingst)\
**Post date:** [June 18, 2024, 9:54pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/8 "2024-06-18T21:54:12Z")

</div>

I had this same problem. I ran **sudo dnf install python3.12-pip** on the ansible controller, and then ran **python3.12 -m pip install --user ansible-pylibssh** , and then I was able to run my playbook.

---

<div class="post-metadata">

**Author:** ![johntxjw](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/johntxjw/32/3520_2.png) [@johntxjw](https://forum.ansible.com/u/johntxjw)\
**Post date:** [June 18, 2024, 10:53pm UTC](https://forum.ansible.com/t/ansible-pylibssh-import-error/6092/9 "2024-06-18T22:53:10Z")

</div>

I believe issue has been solved but I’m not sure what happened.

about 2 days ago I installed it again using “pip3 install --user ansible-pylibssh” and everything installed correctly and ansible works now

like i said it works now lol
