-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to import the required Python library (hcloud-python) #139
Comments
not a bug I assume you installed ansible with python2 pip. But hcloud is python3 only. You should consider to use python3 venv anyway to be independend of systems python and OS.
|
Hi resmo, The only laptop where this is working is on a MacBook Pro (Python 3.9 and hcloud 1.12). |
Debian packages for ansible used to rely on python2 and that is why it will not use python3 libraries. Install ansible in a venv for python3 as I posted. |
Bonjour @resmo Now the problem with hcloud is gone, but now a SSH key not found error shows up... ;-) When running Ansible in a virtual environment, does it lookup for files outside the virtual env? or is limited only to it? |
@jobetinfosec lookup is not limited to the venv, the venv is only for python dependency it is not a "container" or a "secured environment" Nevertheless, I tested it and confirm this worked.
|
Same here on arch-linux Ansible reports $ /usr/bin/python --version
Python 3.9.7
$ pip --version
pip 20.3.4 from /usr/lib/python3.9/site-packages/pip (python 3.9)
$ pip install hcloud-python
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement hcloud-python
ERROR: No matching distribution found for hcloud-python
$ pip install hcloud
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: hcloud in /home/user/.local/lib/python3.9/site-packages (1.16.0) SOLVED: |
I have the same issue ansible-playbook -vvv server-create-init.yml my playbook
Task:
Can not find any solves of this issue (hcloud-python) . Could you please help with solution? root@ip-172-31-27-151:/usr/bin# pip install ansible hcloud-python
root@ip-172-31-27-151:/usr/bin# python3 --version
/etc/ansible/hosts
root@ip-172-31-27-151:/usr/bin# cat /etc/os-release
|
I just wanted to check in and say the same thing started happening to me about 4 days ago as well. I was out of office for the weekend and only noticed today(monday) |
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
Having the same issue here, on Mac OS Monterey with Python/Pip 3.10 EDIT: For anyone encountering this error, while the error message calls the package
|
Maybe this can help someone in the future: # hosts.yml
---
all:
hosts:
ansible:
ansible_host: localhost
ansible_connection: local # TestPlaybook.yml
---
- name: Get some infos
hosts: ansible
gather_facts: false
tasks:
- name: Gather facts about the cloud # <-- Fails
hetzner.hcloud.hcloud_server_info:
name: "testhost"
api_token: "{{ hetzner_cloud_api_token }}" Therefore ansible set the python3 interpreter to # TestPlaybook.yml
---
- name: Get some infos
hosts: localhost
gather_facts: false
tasks:
- name: Gather facts about the cloud # <-- Fails
hetzner.hcloud.hcloud_server_info:
name: "testhost"
api_token: "{{ hetzner_cloud_api_token }}" Were are wondering about why the python interpreter in the venv does import the library without errors because it is just a symbolic link to |
Bug Report
Current Behavior
When running an Ansible script, an error shows up and the script stops:
"Failed to import the required Python library (hcloud-python) on computer's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location."
Input Code
Expected behavior/code
Virtual server creation
Environment
The text was updated successfully, but these errors were encountered: