I want to set up a venv with the following packages as these are specified in a project I'm working on:
ionoscloud==6.1.4
pytest==6.2.5
pytest-cov==3.0.0
ansible==5.0.1
PyYAML==6.0
kubernetes==24.2.0
pyOpenSSL==22.0.0
requests==2.28.1
urllib3==1.26.1
netaddr==0.8.0
I use the following steps:
$ mkdir venv
$ cd venv
$ python -m venv .
$ cp /path/to/requirements.txt .
$ source bin/activate
$ pip install -r requirements.txt
After that, I enter ansible --version
(or anything) and get the following output:
ERROR! Unexpected Exception, this is probably a bug: '_AnsiblePathHookFinder' object has no attribute 'find_spec'
the full traceback was:
Traceback (most recent call last):
File "/home/arbeit/code/virtual-environments/venv/bin/ansible", line 97, in <module>
mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arbeit/code/virtual-environments/venv/lib/python3.12/site-packages/ansible/cli/__init__.py", line 21, in <module>
from ansible.inventory.manager import InventoryManager
File "/home/arbeit/code/virtual-environments/venv/lib/python3.12/site-packages/ansible/inventory/manager.py", line 39, in <module>
from ansible.utils.helpers import deduplicate_list
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1322, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1262, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1528, in find_spec
File "<frozen importlib._bootstrap_external>", line 1502, in _get_spec
AttributeError: '_AnsiblePathHookFinder' object has no attribute 'find_spec'
- My
python --version
returnsPython 3.12.4
which I installed via my distro (pacman/Arch) - The same requirements used to work before, so I assume this is related to my distro updating to the latest python version
- In a new venv where I just
pip install ansible
, I can run Ansible just fine - I installed Python 3.7 as well and set up an venv with that, to no success. Ansible probably calls /usr/bin/python and I'm not sure how to make it use 3.7
I'd be happy for hints what could be wrong here.