# How to add option for pip3 install command in execution-environment.yml?

**URL:** <https://forum.ansible.com/t/how-to-add-option-for-pip3-install-command-in-execution-environment-yml/40249>\
**Category:** Get Help\
**Tags:** aap, ee\
**Created:** [February 13, 2025, 6:18pm UTC](https://forum.ansible.com/t/how-to-add-option-for-pip3-install-command-in-execution-environment-yml/40249 "2025-02-13T18:18:47Z")\
**Posts on this page:** 4\
**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 13, 2025, 6:18pm UTC](https://forum.ansible.com/t/how-to-add-option-for-pip3-install-command-in-execution-environment-yml/40249/1 "2025-02-13T18:18:47Z")

</div>

I am using AAP execution environment feather and trying to build a customized image for that. I have python packages need to be installed to the custom image. I have them listed in requierments.txt file. I believe ansible-builder uses pip3 to install them. But how can I pass some options? For example, I want to install XYZ python package. I can run:

pip3 install --user XYZ==2.1.0.0

In execution-environment.yml, how can I achieve this? If I do

additional\_build\_steps:  
prepend\_base: RUN pip3 install --user XYZ

What is the impact to XYZ I listed in requirements.txt?

Thanks,

J

---

<div class="post-metadata">

**Author:** ![iwt-cmd](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwt-cmd/32/9120_2.png) [@iwt-cmd](https://forum.ansible.com/u/iwt-cmd)\
**Post date:** [February 13, 2025, 6:46pm UTC](https://forum.ansible.com/t/how-to-add-option-for-pip3-install-command-in-execution-environment-yml/40249/2 "2025-02-13T18:46:01Z")

</div>

Hi jzhang2006,

If you already have a requirements.txt file then you can pass that directly into your execution-environment.yml by using the dependencies option. I’ve always kept it in the same root folder as the execution-environment.yml so not sure if it supports paths. Example below:

```auto
version: 3

images:
  base_image:
    name: 'registry.redhat.io/ansible-automation-platform-25/ee-minimal-rhel9:latest'

dependencies:
  galaxy: requirements.yml
  python: requirements.txt

```

The ansible-builder docs have an example that includes a lot of formatting variations. [Execution environment definition — Ansible Builder Documentation](https://ansible.readthedocs.io/projects/builder/en/latest/definition/#version-3-sample-file)

I have broken out to a shell/container commands under the addtional\_build\_steps when I needed to do something like a non-standard package location or the like but that’s not the norm in my experience. The method above has worked well for our builds.

If you’re getting a build error, feel free to post that back and I’ll be happy to take a look.

\*note: updated base\_image to include a real image to avoid confusion.

---

<div class="post-metadata">

**Author:** ![iwt-cmd](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwt-cmd/32/9120_2.png) [@iwt-cmd](https://forum.ansible.com/u/iwt-cmd)\
**Post date:** [February 13, 2025, 6:59pm UTC](https://forum.ansible.com/t/how-to-add-option-for-pip3-install-command-in-execution-environment-yml/40249/3 "2025-02-13T18:59:01Z")

</div>

Hi jzhang2006,

Apologies for the double post, just re-read your original question (will do a better job at that in the future). For other options like “–user”, I’ve had to put them in the additional\_build\_steps similar to what you have listed. I usually execute them in the append\_final step as we’ve moved to version 3 for most of our configs. Depending on where in the build process you may need to use a different option. The link in my first post has some good references. In this example we were having issues getting pywinrm[kerberos] to install via the requirements.txt and moved to doing it after the main build steps were finished.

```auto
version: 3

images:
  base_image:
    name: 'registry.redhat.io/ansible-automation-platform-25/ee-minimal-rhel9:latest'

dependencies:
  galaxy: requirements.yml
  python: requirements.txt

additional_build_files:
  - src: krb5.conf
    dest: krb5.conf

additional_build_steps:
  append_final:
    - RUN pip3 install --upgrade pip
    - RUN pip3 install pywinrm[kerberos]
    - COPY _build/krb5.conf /etc/

```

---

<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, 10:33pm UTC](https://forum.ansible.com/t/how-to-add-option-for-pip3-install-command-in-execution-environment-yml/40249/4 "2025-02-15T22:33:52Z")

</div>

I use pip3 install -t \<package\_path\> and it works as expected.

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

Thanks,

J
