# boto3/botocore errors with aws\_ec2 plugin

**URL:** <https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427>\
**Category:** Get Help\
**Tags:** aws\
**Created:** [September 5, 2025, 4:11pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427 "2025-09-05T16:11:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasmartin](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jasmartin](https://forum.ansible.com/u/jasmartin)\
**Post date:** [September 5, 2025, 4:11pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/1 "2025-09-05T16:11:39Z")

</div>

Hello, I’m pretty new to ansible. Our group has been using 2.10.17 which has been running fine. I was looking to get the latest version working, but I keep running into an issue with the aws\_ec2 plugin. When I check a playbook that references that plugin, I get an error that boto3 or botocore is not installed:

```auto
Using inventory plugin 'ansible_collections.amazon.aws.plugins.inventory.aws_ec2' to process inventory source '/Users/jasmartin/Documents/GitHub/SOLENG-smc-ansible-legacy/inventory/production/smc/aws_ec2.yaml'
[WARNING]: * Failed to parse /Users/jasmartin/Documents/GitHub/SOLENG-smc-ansible-legacy/inventory/production/smc/aws_ec2.yaml with auto plugin: Failed to import the required Python library (botocore and boto3) on
<localhost>'s Python /Users/jasmartin/venv312/bin/python3. 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’m running ansible in a virtual environment and the libraries are there:

```auto
% pip list | grep boto jasmartin@HF7FF70F95
boto3 1.40.24
botocore 1.40.24

```

I’ve been struggling with this and would appreciate any assistance, thanks!

---

<div class="post-metadata">

**Author:** ![jrglynn2](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jrglynn2](https://forum.ansible.com/u/jrglynn2)\
**Post date:** [September 5, 2025, 5:44pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/2 "2025-09-05T17:44:00Z")

</div>

Is Ansible running under the same user or Python Virtual Environment as you running the pip list command?

Any times I have seen similar issues, it’s because Ansible is running either under a different Python than you think, or a different user (like accidentally using `sudo` / `become: true` )

---

<div class="post-metadata">

**Author:** ![jasmartin](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jasmartin](https://forum.ansible.com/u/jasmartin)\
**Post date:** [September 5, 2025, 7:03pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/3 "2025-09-05T19:03:16Z")

</div>

Yes, it’s all running in the same venv:

```auto
zsh 1730 % which ansible
/Users/jasmartin/venv312/bin/ansible
zsh 1731 % which pip                                                                                                                                                                                         
/Users/jasmartin/venv312/bin/pip

```

---

<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:** [September 6, 2025, 7:23am UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/4 "2025-09-06T07:23:07Z")

</div>

How did you create the venv? which python did you use?

---

<div class="post-metadata">

**Author:** ![tremble](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tremble/32/247_2.png) [@tremble](https://forum.ansible.com/u/tremble)\
**Post date:** [September 8, 2025, 8:37am UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/5 "2025-09-08T08:37:40Z")

</div>

The check being used is relatively simplistic, it tries importing botocore and boto3, and raises that error if it fails.

Given it’s explicitly mentioning that it’s running using `/Users/jasmartin/venv312/bin/python3` I suspect you’ve got the right Python environment being used. It’s possible something’s gone wrong with the module dependencies. Something else to try would be running the python shell and trying to import botocore and boto3:

```auto
$ python

import boto3
import botocore

```

For example:

```auto
[10:39:36+0200] ~/vcs/ansible/ansible_collections/amazon/aws [f619c878c|main|⚑ 6]
[✔ (1s) mchappel@mchappel-thinkpadt14gen3 aws] $ python3.12 
Python 3.12.11 (main, Jun 12 2025, 00:00:00) [GCC 15.1.1 20250521 (Red Hat 15.1.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'boto3'
>>> 

```

vs

```auto
(ansible-dev311) 
[10:39:51+0200] ~/vcs/ansible/ansible_collections/amazon/aws [f619c878c|main|⚑ 6]
[✔ (3s) mchappel@mchappel-thinkpadt14gen3 aws] $ python
Python 3.11.13 (main, Jun 4 2025, 00:00:00) [GCC 15.1.1 20250521 (Red Hat 15.1.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> 

```

This shouldn’t raise an error, if it does then we’ve got more info on the actual problem. Occasionally I’ve seen modules raise ImportError exceptions for dependencies or bad configuration files.

---

<div class="post-metadata">

**Author:** ![jasmartin](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jasmartin](https://forum.ansible.com/u/jasmartin)\
**Post date:** [September 8, 2025, 10:23am UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/6 "2025-09-08T10:23:15Z")

</div>

I’m on MacOS with homebrew installed and have python 3.13.7:

```auto
zsh 1533 % which python3 jasmartin@HF7FF70F95
/opt/homebrew/bin/python3
zsh 1615 % python3 -V jasmartin@HF7FF70F95
Python 3.13.7

```

I made the venv with the standard venv creation command:

```auto
 python3 -m venv venv312

```

---

<div class="post-metadata">

**Author:** ![jasmartin](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jasmartin](https://forum.ansible.com/u/jasmartin)\
**Post date:** [September 8, 2025, 10:27am UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/7 "2025-09-08T10:27:56Z")

</div>

I do get an error when I try to import boto3:

```auto
zsh 1796 % /Users/jasmartin/venv312/bin/python3 jasmartin@HF7FF70F95
Python 3.13.7 (main, Aug 14 2025, 11:12:11) [Clang 17.0.0 (clang-1700.0.13.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import boto3
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/boto3/ __init__.py", line 18, in <module>
    from boto3.session import Session
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/botocore/client.py", line 15, in <module>
    from botocore import (
    ...<3 lines>...
    )
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/botocore/waiter.py", line 20, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/botocore/docs/ __init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/botocore/docs/service.py", line 13, in <module>
    from botocore.docs.bcdoc.restdoc import DocumentStructure
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/botocore/docs/bcdoc/restdoc.py", line 17, in <module>
    from botocore.compat import OrderedDict
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/botocore/compat.py", line 31, in <module>
    from dateutil.tz import tzlocal
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/dateutil/tz/ __init__.py", line 2, in <module>
    from .tz import *
  File "/Users/jasmartin/venv312/lib/python3.13/site-packages/dateutil/tz/tz.py", line 21, in <module>
    from six.moves import _thread
ModuleNotFoundError: No module named 'six.moves'

```

Although I have the six library installed:

```auto
zsh 1799 [1] % /Users/jasmartin/venv312/bin/pip install six 1 ↵ jasmartin@HF7FF70F95
Requirement already satisfied: six in ./venv312/lib/python3.13/site-packages (1.17.0)

```

---

<div class="post-metadata">

**Author:** ![tremble](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tremble/32/247_2.png) [@tremble](https://forum.ansible.com/u/tremble)\
**Post date:** [September 8, 2025, 12:02pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/8 "2025-09-08T12:02:11Z")

</div>

> [@jasmartin](#):
>
> ```auto
> ModuleNotFoundError: No module named 'six.moves'
> 
> ```

This feels familiar, and I think there’s an issue with six…

> <https://stackoverflow.com/questions/13967428/importerror-no-module-named-six/79272230#79272230>

> Pinning the version to `six==1.16.0` fixes the issue.

I’m not sure this is something we can really “fix” in the collection, and we’re not hitting it in CI. I’ve a vague memory that it’s tied to both Python 3.12 and six 1.17…

---

<div class="post-metadata">

**Author:** ![jasmartin](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jasmartin](https://forum.ansible.com/u/jasmartin)\
**Post date:** [September 8, 2025, 12:42pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/9 "2025-09-08T12:42:52Z")

</div>

I believe that was it. I switched back to using python 3.9 and I’m not getting the error, thanks!

---

<div class="post-metadata">

**Author:** ![tremble](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tremble/32/247_2.png) [@tremble](https://forum.ansible.com/u/tremble)\
**Post date:** [September 8, 2025, 1:13pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/10 "2025-09-08T13:13:08Z")

</div>

IIRC you can also bump up to Python 3.13 to clear the error. Ansible Core (including the “ansible” tool itself) is dropping support for older versions of Python on the controllers fairly aggressively.

See also: [Releases and maintenance — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html)

Additionally, Ansible Core \< 2.17 is no longer supported by upstream, and the collection isn’t **tested** on anything older than 2.17. For controllers, Ansible Core 2.17 requires Python 3.10 or later.

---

<div class="post-metadata">

**Author:** ![jasmartin](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jasmartin](https://forum.ansible.com/u/jasmartin)\
**Post date:** [September 8, 2025, 1:39pm UTC](https://forum.ansible.com/t/boto3-botocore-errors-with-aws-ec2-plugin/44427/11 "2025-09-08T13:39:14Z")

</div>

Actually I was using 3.13 for the test and was getting six.moves error with it, I had the venv named incorrectly.
