# Trouble with python bindings error (libselinux-python not installed) on RHEL8

**URL:** <https://forum.ansible.com/t/trouble-with-python-bindings-error-libselinux-python-not-installed-on-rhel8/33465>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [July 22, 2020, 10:11pm UTC](https://forum.ansible.com/t/trouble-with-python-bindings-error-libselinux-python-not-installed-on-rhel8/33465 "2020-07-22T22:11:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robbie](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Robbie](https://forum.ansible.com/u/Robbie)\
**Post date:** [July 22, 2020, 10:11pm UTC](https://forum.ansible.com/t/trouble-with-python-bindings-error-libselinux-python-not-installed-on-rhel8/33465/1 "2020-07-22T22:11:41Z")

</div>

Hello all.

I’ve been trying to troubleshoot a problem for days and I haven’t been able to find anything online that refers to RHEL8/Centos8.I have success running on RHEL/Centos7, but I’m trying to push to the new platform. Ikeep getting this error:

` TASK [genjson: Generate F5 JSON - Nodes] **************************************************************************************************************************************************** task path: /home/admsplitb/Lab-Infrastructure/roles/f5_dclb/tasks/main.yml:6 fatal: [`genjson`-1]: FAILED! =\> {“changed”: false, “checksum”: “60caf69c5c72c2814e3b1688a9564a86205778ed”, “msg”: “Aborting, target uses selinux but python bindings (libselinux-python) aren’t installed!”}

`

My version of ansible and python

`(py3venv) [user@lab playbooks]$ ansible --version ansible 2.9.11 config file = /home/user/Lab-Infrastructure/playbooks/ansible.cfg ansible python module location = /home/user/py3venv/lib64/python3.8/site-packages/ansible executable location = /home/user/py3venv/bin/ansible python version = 3.8.0 (default, Mar 9 2020, 18:02:46) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]`

I tried to link previous packages as indicated in [this github issue](https://github.com/ansible-community/molecule/issues/1724#issuecomment-460610492)

First ensuring that the packages are installed:

```auto

yum install libselinux-python

```

And then linking the files to your environment.

`cd ~/py3venv/lib64/python3.8/site-packages/ ln -s /usr/lib64/python3.6/site-packages/selinux ln -s /usr/lib64/python3.6/site-packages/_selinux.cpython-36m-x86_64-linux-gnu.so`

```auto

```

But in RHEL8, the package names have changed.  
`  
yum install libselinux  
yum install python3-libselinux

`

Anybody experience this and solve it yet?

---

<div class="post-metadata">

**Author:** ![Robbie](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Robbie](https://forum.ansible.com/u/Robbie)\
**Post date:** [July 27, 2020, 1:22pm UTC](https://forum.ansible.com/t/trouble-with-python-bindings-error-libselinux-python-not-installed-on-rhel8/33465/2 "2020-07-27T13:22:41Z")

</div>

I made some slight progress, but haven’t figured out how to get this to work entirely in my py3venv.

With some troubleshooting, I noticed the following: setup is reporting that selinux is present.

`  
(py3venv) [user@lab playbooks]$ ansible -m setup -i rawhide.vgr, all | grep selinux  
“ansible\_selinux”: {  
“ansible\_selinux\_python\_present”: true,

(py3venv) [`user@lab playbooks`]$ which ansible  
~/py3venv/bin/ansible

`

But when I try to ensure that my python interpreter is the one from my virtual py3venv environment, I recieve present: false. I tried this for

` (py3venv) [`user@lab playbooks`]$ ansible -e ‘ansible\_python\_interpreter=~/py3venv/bin/python3’ -m setup -i rawhide.vgr, all | grep selinux  
“ansible\_selinux”: {  
“status”: “Missing selinux Python library”  
“ansible\_selinux\_python\_present”: false,

`

I tried these following as parameters for the `ansible_python_interpreter. H```ere are the responses.

False /usr/bin/python  
False /usr/bin/python3

False ~/py3venv/bin/python  
False ~/py3venv/bin/python3

True /usr/libexec/platform-python

So, if i run my original command with the final ansible interpreter, it works.

`  
ansible-playbook -e ‘ansible\_python\_interpreter=/usr/libexec/platform-python’ playbook.yml

`

How can I get my python3 virtual environment to work like I want it to?
