# EE default ansible python module location is different from pip3 installation location

**URL:** <https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293>\
**Category:** Get Help\
**Tags:** aap, ee\
**Created:** [February 15, 2025, 11:12pm UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293 "2025-02-15T23:12:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzhang2006](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jzhang2006](https://forum.ansible.com/u/jzhang2006)\
**Post date:** [February 15, 2025, 11:12pm UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/1 "2025-02-15T23:12:46Z")

</div>

I am using ansible-builder 3.1.0 with redhat base image ansible-automation-platform-24/ee-supported-rhel8:1.0.0-887 to build an EE image for AAP 2.4. I am facing an issue: EE default ansible python module location is different than pip3 installation location:

EE default ansible python module location = /usr/lib/python3.9/site-packages/ansible  
pip3 installed location default to: /usr/local/lib/python3.9/site-packages

My use case is to install PyU4V for a storage collection. Even PyU4V is installed from pip3 perspective but the collection can’t find it.

I tried to twist execution-environment.yml to run pip3:

RUN pip3 install -t /usr/lib/python3.9/site-packages/ansible PyU4V==10.1.0.0

The PyU4V is installed in /usr/lib/python3.9/site-packages/ansible directory but the collection still can’t find it.

I don’t think I can use PYTHONPATH with ansible-builder as it only works with a user’s shell session scope. Is there anything I am missing here?

Thanks!

J

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [February 16, 2025, 2:20am UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/2 "2025-02-16T02:20:50Z")

</div>

> [@jzhang2006](#):
>
> I tried to twist execution-environment.yml to run pip3:
> 
> RUN pip3 install -t /usr/lib/python3.9/site-packages/ansible PyU4V==10.1.0.0
> 
> The PyU4V is installed in /usr/lib/python3.9/site-packages/ansible directory but the collection still can’t find it.

Try `RUN pip3 install -t /usr/lib/python3.9/site-packages PyU4V==10.1.0.0`

You want pip packages to be installed under `site-packages`, not a sub directory of it. That said, it might be better to try installing `dnf install python3.9-PyU4V` if it exists in AppStream.

---

<div class="post-metadata">

**Author:** ![wayt](https://avatars.discourse-cdn.com/v4/letter/w/3be4f8/32.png) [@wayt](https://forum.ansible.com/u/wayt)\
**Post date:** [February 16, 2025, 3:36am UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/3 "2025-02-16T03:36:38Z")

</div>

Given the Python module in question I assume you are wanting to use the `dell.powermax` collection in the EE. The following `execution-environment.yml` produces an EE that contains `PyU4V <= 10.1.0.2` which is required by the code within the module.

```yml
---
additional_build_steps:
  append_base:
    - RUN $PYCMD -m pip install --upgrade pip

dependencies:
  galaxy: |-
    collections:
      - name: dellemc.powermax
        version: 3.1.0
  python:
    - PyU4V <= 10.1.0.2

images:
  base_image:
    name: registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:1.0.0-887

options:
  package_manager_path: /usr/bin/microdnf

version: 3

```

The collection does have a `requirements.txt` but it doesn’t limit the version that is installed so as of right now if you use PyPi you get a version that’s newer than what is supported.

```bash
    "msg": "PyU4V 10.2.0.2 is not supported by this module.Minimum supported version is : 9.1.2.0 and less than 10.1.0.2 "

```

We use the additional Python requirement to constrain it back to a version that will work with the collection.

I posted an issue that should help to resolve this. Also let me know here if you are trying to install this module but not use the `dell.powermax` collection.

> <https://github.com/dell/ansible-powermax/issues/66>
>
> \*\*Describe the bug\*\*
> 
> The \`ansible-builder\` tool introspects collections and wil…l install Python dependencies automatically. The \`requirements.txt\` in this collection isn't constrained so when a version lands on PyPi that is newer than what the collection supports the \`ansible-builder\` tool installs it and users fail to create an EE easily with an appropriate version of the Python module.
> 
> \*\*To Reproduce\*\*
> 
> Steps to reproduce the behavior:
> 1. Create an \`execution-environment.yml\` like so:
> 
> \`\`\`yml
> \---
> additional\_build\_steps:
> append\_base:
> - RUN $PYCMD -m pip install --upgrade pip
> 
> dependencies:
> galaxy: |-
> collections:
> - name: dellemc.powermax
> version: 3.1.0
> 
> images:
> base\_image:
> name: registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:1.0.0-887
> 
> options:
> package\_manager\_path: /usr/bin/microdnf
> 
> version: 3
> \`\`\`
> 
> 2. Build the EE with \`ansible-builder --tag forums-40293:v3 --verbosity 3\`
> 3. Try to use the EE against a Dell PowerMax
> 
> \*\*Expected behavior\*\*
> 
> That \`ansible-builder\` dependency introspection works.
> 
> \*\*Additional context\*\*
> 
> 
> \*\*Workaround\*\*
> 
> Constrain the Python version with the following added to the \`execution-environment.yml\`
> 
> \`\`\`yml
> \---
> additional\_build\_steps:
> append\_base:
> - RUN $PYCMD -m pip install --upgrade pip
> 
> dependencies:
> galaxy: |-
> collections:
> - name: dellemc.powermax
> version: 3.1.0
> python:
> - PyU4V \<= 10.1.0.2
> 
> images:
> base\_image:
> name: registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:1.0.0-887
> 
> options:
> package\_manager\_path: /usr/bin/microdnf
> 
> version: 3
> \`\`\`

---

<div class="post-metadata">

**Author:** ![jzhang2006](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jzhang2006](https://forum.ansible.com/u/jzhang2006)\
**Post date:** [February 16, 2025, 6:07am UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/4 "2025-02-16T06:07:33Z")

</div>

Hi Caleb,

I follow your suggestion and fixed it:

RUN pip3 install -t /usr/lib/python3.9/site-packages PyU4V==10.1.0.0

The PyU4V is installed in /usr/lib/python3.9/site-packages. My playbook pre-task verified the installation by pip3 show PyU4V and it suceeds. But my followed task that depends on this package failed due to not finding it. Here is the playbook snippet:

* * *

- name: Create Storage Group  
hosts: create\_storagegroup  
connection: local  
gather\_facts: false

The error shows: “Ansible modules for PowerMax require the PyU4V python library to be installed. Install the library before using these modules.”

Thanks,

J

---

<div class="post-metadata">

**Author:** ![jzhang2006](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jzhang2006](https://forum.ansible.com/u/jzhang2006)\
**Post date:** [February 16, 2025, 6:35am UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/5 "2025-02-16T06:35:01Z")

</div>

Hi Tim,

Yes, I am working with dell.powermax collection. My execution-environment.yml is very similar to yours. It still not working.

* * *

version: 3

dependencies:  
galaxy: files/requirements.yml  
python:  
- PyU4V \<= 10.1.0.2  
system: files/bindep.txt

images:  
base\_image:  
name: ‘[registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:1.0.0-887](http://registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:1.0.0-887)’

additional\_build\_steps:  
append\_base:  
- RUN $PYCMD -m pip install --upgrade pip

# use microdnf as the base image is minimal one

options:  
package\_manager\_path: /usr/bin/microdnf

The requiremens.yml under files directory:

* * *

collections:

# Install Dell EMC Ansible modules for PowerMax

- name: “[GitHub - dell/ansible-powermax: Ansible Modules for Dell PowerMax](https://github.com/dell/ansible-powermax.git)”  
type: git  
version: “3.1.0” # tag

As this ee file does not force PyU4V to be installed in /usr/lib/python3.9/site-packages. It goes to  
/usr/local/lib/python3.9/site-packages. AAP log shows:

ansible-playbook [core 2.15.13]  
config file = /etc/ansible/ansible.cfg  
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
**ansible python module location = /usr/lib/python3.9/site-packages/ansible**  
ansible collection location = /runner/requirements\_collections:/root/.ansible/collections:/usr/share/ansible/collections  
executable location = /usr/bin/ansible-playbook  
python version = 3.9.20 (main, Sep 26 2024, 20:59:47) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/usr/bin/python3.9)  
jinja version = 3.1.5  
libyaml = True  
Using /etc/ansible/ansible.cfg as config file  
…  
…  
“stdout\_lines”: [  
“Name: PyU4V”,  
“Version: 10.1.0.2”,  
“Summary: A Python library for use with Dell EMC’s Unisphere for PowerMax REST API.”,  
“Home-page: [GitHub - dell/PyU4V: PyU4V is a Python module that simplifies interaction with the Unisphere for PowerMax REST API. It wraps REST calls with simple APIs that abstracts the HTTP request and response handling.](https://github.com/dell/PyU4V/)”,  
“Author: Dell Inc. or its subsidiaries”,  
“Author-email: [helen.walsh@dell.com](mailto:helen.walsh@dell.com)”,  
“License: Apache 2.0”,  
“ **Location: /usr/local/lib/python3.9/site-packages** ”,  
“Requires: prettytable, requests, six, sphinx-rtd-theme, urllib3”,  
“Required-by: #N/A”  
]

The create\_storagegroup role failed due to: “Ansible modules for PowerMax require the PyU4V python library to be installed. Install the library before using these modules”

By the way, the play runs totally fine if I did it on a VM (not with AAP). It only fails in AAP (which is installed with containerized way).

Thanks,

J

---

<div class="post-metadata">

**Author:** ![wayt](https://avatars.discourse-cdn.com/v4/letter/w/3be4f8/32.png) [@wayt](https://forum.ansible.com/u/wayt)\
**Post date:** [February 16, 2025, 2:52pm UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/6 "2025-02-16T14:52:21Z")

</div>

Try installing the Python dependency the way show vs using pip commands.

---

<div class="post-metadata">

**Author:** ![jzhang2006](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jzhang2006](https://forum.ansible.com/u/jzhang2006)\
**Post date:** [February 16, 2025, 10:04pm UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/7 "2025-02-16T22:04:09Z")

</div>

Hi Tim,

Yes, I did what you showed and it is the same results. What version of ansible-builder you used? Do you see ’ **ansible python module location = /usr/lib/python3.9/site-packages/ansible** ’ in AAP template output?

J

---

<div class="post-metadata">

**Author:** ![wayt](https://avatars.discourse-cdn.com/v4/letter/w/3be4f8/32.png) [@wayt](https://forum.ansible.com/u/wayt)\
**Post date:** [February 17, 2025, 3:33pm UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/8 "2025-02-17T15:33:40Z")

</div>

> [@jzhang2006](#):
>
> Yes, I did what you showed and it is the same results. What version of ansible-builder you used? Do you see ’ **ansible python module location = /usr/lib/python3.9/site-packages/ansible** ’ in AAP template output?

I used `ansible-builder==3.1.0`. The way I express the dependencies will allow `ansible-builder` to specify the correct Python installation that is related to `ansible`. I too see `ansible` using `/usr/bin/python3.9` (aka `/usr/lib/python3.9/site-packages`)

Avoiding `pip3` in the `execution-environment.yml` is probably a good idea especially since we’re given a method to directly express Python dependencies. That said I can confirm that both `/usr/lib<64>` and `/usr/local/lib<64>` are both searched. From within the container you can see the search path for the Python modules:

```bash
bash-4.4$ python3 -m site   
sys.path = [
    '/runner',
    '/usr/lib64/python39.zip',
    '/usr/lib64/python3.9',
    '/usr/lib64/python3.9/lib-dynload',
    '/usr/local/lib64/python3.9/site-packages',
    '/usr/local/lib/python3.9/site-packages',
    '/usr/lib64/python3.9/site-packages',
    '/usr/lib/python3.9/site-packages',
]
USER_BASE: '/runner/.local' (doesn't exist)
USER_SITE: '/runner/.local/lib/python3.9/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

```

Prior to uploading your built image your registry and launched via AAP2 you can test it with `ansible-navigator` or `podman` directly.

---

<div class="post-metadata">

**Author:** ![jzhang2006](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jzhang2006](https://forum.ansible.com/u/jzhang2006)\
**Post date:** [February 17, 2025, 8:10pm UTC](https://forum.ansible.com/t/ee-default-ansible-python-module-location-is-different-from-pip3-installation-location/40293/9 "2025-02-17T20:10:31Z")

</div>

It’s working now. I missed adding ansible\_python\_interpreter: ‘/usr/bin/python3’ to the inventory. EE stuffs are all good.

Thanks a lot for the help!

J
