# python error during task

**URL:** <https://forum.ansible.com/t/python-error-during-task/36890>\
**Category:** Ansible Project\
**Created:** [July 22, 2022, 6:34pm UTC](https://forum.ansible.com/t/python-error-during-task/36890 "2022-07-22T18:34:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdidomenico](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mdidomenico](https://forum.ansible.com/u/mdidomenico)\
**Post date:** [July 22, 2022, 6:34pm UTC](https://forum.ansible.com/t/python-error-during-task/36890/1 "2022-07-22T18:34:43Z")

</div>

sorry for the cross post, i sent this to the devel list by mistake

---

<div class="post-metadata">

**Author:** ![mdidomenico](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mdidomenico](https://forum.ansible.com/u/mdidomenico)\
**Post date:** [July 22, 2022, 7:56pm UTC](https://forum.ansible.com/t/python-error-during-task/36890/2 "2022-07-22T19:56:58Z")

</div>

for anyone that might come across this in the future, it looks like  
this might boil down to a dependecy hell problem

python3 and ansible2.13 require 37.0.4 which is not compatible with python2.7

the yum utils require python2 in order to run, which are not  
compatible with cryptography or python3. so when you use 'package' in  
an ansible playbook, it spawns /usr/bin/python (which is 2.7 in my) to  
run the yum utils.

you might think i could switch to ansible.builtin.dnf which is python3  
compatible, however, python3-dnf doesn't exist on rhel7, only rhel8

i might not have that all straight, but that's the jist of it

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [July 23, 2022, 5:46am UTC](https://forum.ansible.com/t/python-error-during-task/36890/3 "2022-07-23T05:46:50Z")

</div>

Compiling everything correctly is not trivial - as you found out. What is the reason you’re doing this? And not use one of the recommended installation methods?

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [July 23, 2022, 11:35am UTC](https://forum.ansible.com/t/python-error-during-task/36890/4 "2022-07-23T11:35:35Z")

</div>

This is the problem that _Execution Environments_ allow you to avoid.

Or, if you’re rather more cynical, this is the type of problem that emerges due to relying on execution environments.

RHEL7 users - myself included, paying for the privilege, thanks - might feel put out that a supported operating system/distro doesn’t have a path forward from python2, but in fact it does: it’s “move to RHEL8 or RHEL9.” I shouldn’t be surprised that I can’t get a Mr. Fusion adaptor for my Edsel. Technically, python3 can “be done” on RHEL7, but why put the effort into digging your technical debt hole even deeper. (And by “you” I mean “me”, because I’m really arguing myself into scrapping the Edsel and getting on with life.)

It would be easier to spin up a RHEL8 vm or an execution environment compatible with whatever version of Ansible you want to run than building and running a python3 application environment atop a RHEL7 installation. You’re / I’m solving the wrong problem.

---

<div class="post-metadata">

**Author:** ![Nico\_Kadel-Garcia](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/nico_kadel-garcia/32/9998_2.png) [@Nico\_Kadel-Garcia](https://forum.ansible.com/u/Nico_Kadel-Garcia)\
**Post date:** [July 24, 2022, 10:34am UTC](https://forum.ansible.com/t/python-error-during-task/36890/5 "2022-07-24T10:34:10Z")

</div>

> sorry for the cross post, i sent this to the devel list by mistake  
> ---  
> i have compiled a separate version of openssl 1.1.1, python 3.10.5,  
> and ansible 2.13.2 into my home directory. i have the  
> interpreter\_python set in the ansible.cfg file to point to the version  
> of python in my home directory.

> i'm new to ansible and python, so i'm not sure where the error lies.

May I suggest you stop right there?

First, you're using ansible-core 2.13.2. ansible-core is everything  
that really matters, including the primary ansible tools and modules.  
The "ansible" package is quite useless for most, a bundle of more than  
100 ansible galaxy collection modules. Yes, it's confusing, I've  
argued before that "ansible-core" should have been left named  
"ansible" as it was back with ansible 2.9, and the ansible collection  
should match the name of the directories it actually insalls, namely  
"ansible\_collections". But good luck trying to get \*that\* revised.

So, if you're new to python, why are you trying to hurt yourself by  
building your own python and openssl? We can't even deduce where you  
put them and how you reference them. You're in the position of someone  
new to electronics who decided to make their own battery. One of the  
advantages of the open source and free software world is you can start  
from already working tools, and focus on the bits vital to your  
project. So why are you starting with openssl and python? Ansible is  
designed, when talking to remte hosts, to do a lot of deduction about  
the remote python and use the built-in python there. Based on your  
error messages, that's a RHEL environment with "/usr/bin/python" being  
linked to python 2.7.

If you need to build your own updated ansible-core, may I strongly  
urge you to work from the RHEL published ansible packages, or if you  
need a more recent ansible-core RPM, take a look at my RPM building  
tools over at https:/github.com/n kadel/ansiblerepo/ ? It's quite  
tricky to update ansible-core past version 2.11 on RHEL 7, you need to  
use steps like "pip3 install -user ansible-core"

---

<div class="post-metadata">

**Author:** ![Nico\_Kadel-Garcia](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/nico_kadel-garcia/32/9998_2.png) [@Nico\_Kadel-Garcia](https://forum.ansible.com/u/Nico_Kadel-Garcia)\
**Post date:** [July 24, 2022, 10:55am UTC](https://forum.ansible.com/t/python-error-during-task/36890/6 "2022-07-24T10:55:49Z")

</div>

> This is the problem that Execution Environments allow you to avoid.
> 
> Or, if you're rather more cynical, this is the type of problem that emerges due to relying on execution environments.

That's a pretty fundamental architectural issue, you're unlikely to  
get a lot of traction on installing a local daemon with its own  
functional python on every remote host for ansible execution.

> RHEL7 users - myself included, paying for the privilege, thanks - might feel put out that a supported operating system/distro doesn't have a path forward from python2, but in fact it does: it's "move to RHEL8 or RHEL9." I shouldn't be surprised that I can't get a Mr. Fusion adaptor for my Edsel. Technically, python3 can "be done" on RHEL7, but why put the effort into digging your technical debt hole even deeper. (And by "you" I mean "me", because I'm really arguing myself into scrapping the Edsel and getting on with life.)

It gets funnier that, when ansible makes demands for python modules  
unavailable on contemporary RHEL releases, the response for providing  
RPMS that include them is to violate pretty basic python packaging  
guidelines for Fedora and RHEL and internalize them inside the SRPM,  
with git commit labeled tarballs rather than release numbered  
tarballs. Someone out there decided to get strange and ignora Fedora  
guidelines. I now publish RPM update tools for those dependencies,  
over at [https://github.com/nkadel/ansiblerepo](https://github.com/nkadel/ansiblerepo).

On RHEL 7, if you really need ansible-core 2.13.2, I think we're SOL.  
Building up a fresh python 3.8 or later for it is more work than most  
of us need. Use RHEL 8 or CentOS 8, and use the python38 packages. And  
the published ansible-core 2.12 is plenty for most uses there until,  
for example, RHEL straightens out the modularity mucked up dnf  
installation of the "python38-packaging" package to allow gracefully  
building up the dependency suite for ansible-core 2.13. I ran into  
that last week. I'm pretty unhappy about Red Hat allowing the RPM  
"modularity" pecularities near any system RPMs.

> It would be easier to spin up a RHEL8 vm or an execution environment compatible with whatever version of Ansible you want to run than building and running a python3 application environment atop a RHEL7 installation. You're / I'm solving the wrong problem.

Or docker container.

"python3" isn't so much the problem. You can install with the built-in  
python3 packages for RHEL 7.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sudo yum install python3-devel  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sudo yum install python3-pip  
&nbsp;&nbsp;&nbsp;&nbsp;pip3 install -m ansible-core # will only provide ansible-core up  
to 4.11 on RHEL 7 built-in python 3.6
