Barfs out with "ImportError: No module named pkg_resources"
hasufell opened this issue · comments
TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] ********************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pkg_resources
failed: [jenkins] (item={'name': 'setuptools'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "setuptools"}, "msg": "Failed to import the required Python library (setuptools) on jenkins-machine's Python /usr/bin/python. Please read module documentation and install in the appropriate location"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pkg_resources
failed: [jenkins] (item={'name': 'docker'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "docker"}, "msg": "Failed to import the required Python library (setuptools) on jenkins-machine's Python /usr/bin/python. Please read module documentation and install in the appropriate location"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pkg_resources
failed: [jenkins] (item={'name': 'docker-compose'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "docker-compose"}, "msg": "Failed to import the required Python library (setuptools) on jenkins-machine's Python /usr/bin/python. Please read module documentation and install in the appropriate location"}
The file up until the error:
- hosts: "{{ setupHosts }}"
vars_prompt:
- name: "setupHosts"
prompt: "Which hosts would you like to setup?"
private: no
gather_facts: yes
tasks:
- name: add universe repository for bionic
become: yes
apt_repository:
repo: deb http://archive.ubuntu.com/ubuntu bionic universe
state: present
when: ansible_distribution_release == 'bionic'
- name: install pip
become: yes
import_role:
name: geerlingguy.pip
vars:
pip_package: python3-pip
pip_install_packages:
- name: setuptools
- name: docker
- name: docker-compose
Make sure you have the package python-setuptools
installed. I had the same error and manually installing this package on Debian Buster fixed it for me.
Are you getting those errors using python3
? I was seeing something similar and used the following vars to get things working:
ansible_python_interpreter: /usr/bin/python3
pip_package: python3-pip
pip_executable: pip3
pip_install_packages:
- name: awscli
Please note that I installed python3-pip
in a role tasked before the pip
role.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.