Comments (16)
Hi,
The first line from your error message mentions you're using Python 2.7 for running pip.
Can you install Python 3 on your server and also configure Ansible to use it?
from ansible-docker.
You mean in the server where Ansible is installed right? I will try and let you know, thanks for the quick answer
from ansible-docker.
Yep and then since it sounds like you'll have both Python 2 and 3 installed on your server you'll also want to configure Ansible to use Python 3 as your interpreter. You can set ansible_python_interpreter=/usr/bin/python3
in your inventory or ansible config.
from ansible-docker.
I already have this ansible_python_interpreter=/usr/bin/python3
in my ansible.cfg
from ansible-docker.
Did you modify any configuration? Virtualenv should be installed, it's a part of docker__pip_dependencies
, but it feels like it might be installed in your Python 2 environment somehow.
from ansible-docker.
The first time I ran the role was before I changed ansible_python_interpreter
to py3, that might be the problem, I will update the ansible server to py3 and retry again
from ansible-docker.
So far what I did was reinstall ansible with pip3 as per the documentation, now ansible --version | grep "python version"
gives:
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
controller starting with Ansible 2.12. Current version: 3.7.3 (default, Jan 22
2021, 20:04:44) [GCC 8.3.0]. This feature will be removed from ansible-core in
version 2.12. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
I purged python3 version and the dependencies in the server and reinstalled python3, I still have the same error:
TASK [nickjj.docker : Install Python packages] ************************************************************************************************************************************************************************************************************************
task path: /root/.ansible/roles/nickjj.docker/tasks/main.yml:57
Tuesday 14 September 2021 07:43:26 -0400 (0:00:00.728) 0:00:19.507 *****
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b 10.22.1.139 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/.ansible-${USER}/tmp `"&& mkdir "` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364 `" && echo ansible-tmp-1631619806.8574748-30586-207255618694364="` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364 `" ) && sleep 0'"'"''
<10.22.1.139> (0, b'ansible-tmp-1631619806.8574748-30586-207255618694364=/tmp/.ansible-root/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364\n', b'')
Using module file /usr/local/lib/python3.7/dist-packages/ansible/modules/pip.py
<10.22.1.139> PUT /root/.ansible/tmp/ansible-local-30248ot4zz_9y/tmpzy00amtj TO /tmp/.ansible-root/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364/AnsiballZ_pip.py
<10.22.1.139> SSH: EXEC scp -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b /root/.ansible/tmp/ansible-local-30248ot4zz_9y/tmpzy00amtj '[10.22.1.139]:/tmp/.ansible-root/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364/AnsiballZ_pip.py'
<10.22.1.139> (0, b'', b'')
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b 10.22.1.139 '/bin/sh -c '"'"'chmod u+x /tmp/.ansible-root/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364/ /tmp/.ansible-root/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364/AnsiballZ_pip.py && sleep 0'"'"''
<10.22.1.139> (0, b'', b'')
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b -tt 10.22.1.139 '/bin/sh -c '"'"'/usr/bin/python3 /tmp/.ansible-root/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364/AnsiballZ_pip.py && sleep 0'"'"''
<10.22.1.139> (1, b'\r\n{"failed": true, "msg": "Could not get output from /usr/local/bin/virtualenv --help: Traceback (most recent call last):\\n File \\"/usr/local/bin/virtualenv\\", line 6, in <module>\\n from virtualenv.__main__ import run_with_catch\\nModuleNotFoundError: No module named \'virtualenv.__main__\'; \'virtualenv\' is not a package\\n", "invocation": {"module_args": {"name": ["docker\\n"], "virtualenv": "/usr/local/lib/docker/virtualenv", "virtualenv_python": "python3", "state": "present", "virtualenv_site_packages": false, "virtualenv_command": "virtualenv", "editable": false, "version": null, "requirements": null, "extra_args": null, "chdir": null, "executable": null, "umask": null}}}\r\n', b'Shared connection to 10.22.1.139 closed.\r\n')
<10.22.1.139> Failed to connect to the host via ssh: Shared connection to 10.22.1.139 closed.
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b 10.22.1.139 '/bin/sh -c '"'"'rm -f -r /tmp/.ansible-root/tmp/ansible-tmp-1631619806.8574748-30586-207255618694364/ > /dev/null 2>&1 && sleep 0'"'"''
<10.22.1.139> (0, b'', b'')
failed: [10.22.1.139] (item={'name': 'docker', 'state': 'present'}) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"chdir": null,
"editable": false,
"executable": null,
"extra_args": null,
"name": [
"docker\n"
],
"requirements": null,
"state": "present",
"umask": null,
"version": null,
"virtualenv": "/usr/local/lib/docker/virtualenv",
"virtualenv_command": "virtualenv",
"virtualenv_python": "python3",
"virtualenv_site_packages": false
}
},
"item": {
"name": "docker",
"state": "present"
},
"msg": "Could not get output from /usr/local/bin/virtualenv --help: Traceback (most recent call last):\n File \"/usr/local/bin/virtualenv\", line 6, in <module>\n from virtualenv.__main__ import run_with_catch\nModuleNotFoundError: No module named 'virtualenv.__main__'; 'virtualenv' is not a package\n"
}
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b 10.22.1.139 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/.ansible-${USER}/tmp `"&& mkdir "` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444 `" && echo ansible-tmp-1631619807.3431797-30586-1669652533444="` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444 `" ) && sleep 0'"'"''
<10.22.1.139> (0, b'ansible-tmp-1631619807.3431797-30586-1669652533444=/tmp/.ansible-root/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444\n', b'')
Using module file /usr/local/lib/python3.7/dist-packages/ansible/modules/pip.py
<10.22.1.139> PUT /root/.ansible/tmp/ansible-local-30248ot4zz_9y/tmpe15eh3be TO /tmp/.ansible-root/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444/AnsiballZ_pip.py
<10.22.1.139> SSH: EXEC scp -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b /root/.ansible/tmp/ansible-local-30248ot4zz_9y/tmpe15eh3be '[10.22.1.139]:/tmp/.ansible-root/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444/AnsiballZ_pip.py'
<10.22.1.139> (0, b'', b'')
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b 10.22.1.139 '/bin/sh -c '"'"'chmod u+x /tmp/.ansible-root/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444/ /tmp/.ansible-root/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444/AnsiballZ_pip.py && sleep 0'"'"''
<10.22.1.139> (0, b'', b'')
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b -tt 10.22.1.139 '/bin/sh -c '"'"'/usr/bin/python3 /tmp/.ansible-root/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444/AnsiballZ_pip.py && sleep 0'"'"''
<10.22.1.139> (1, b'\r\n{"failed": true, "msg": "Could not get output from /usr/local/bin/virtualenv --help: Traceback (most recent call last):\\n File \\"/usr/local/bin/virtualenv\\", line 6, in <module>\\n from virtualenv.__main__ import run_with_catch\\nModuleNotFoundError: No module named \'virtualenv.__main__\'; \'virtualenv\' is not a package\\n", "invocation": {"module_args": {"name": ["docker-compose\\n"], "virtualenv": "/usr/local/lib/docker/virtualenv", "virtualenv_python": "python3", "state": "present", "virtualenv_site_packages": false, "virtualenv_command": "virtualenv", "editable": false, "version": null, "requirements": null, "extra_args": null, "chdir": null, "executable": null, "umask": null}}}\r\n', b'Shared connection to 10.22.1.139 closed.\r\n')
<10.22.1.139> Failed to connect to the host via ssh: Shared connection to 10.22.1.139 closed.
<10.22.1.139> ESTABLISH SSH CONNECTION FOR USER: root
<10.22.1.139> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=4222 -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/c0eceb4c2b 10.22.1.139 '/bin/sh -c '"'"'rm -f -r /tmp/.ansible-root/tmp/ansible-tmp-1631619807.3431797-30586-1669652533444/ > /dev/null 2>&1 && sleep 0'"'"''
<10.22.1.139> (0, b'', b'')
failed: [10.22.1.139] (item={'name': 'docker-compose', 'version': '', 'path': '/usr/local/bin/docker-compose', 'src': '/usr/local/lib/docker/virtualenv/bin/docker-compose', 'state': 'present'}) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"chdir": null,
"editable": false,
"executable": null,
"extra_args": null,
"name": [
"docker-compose\n"
],
"requirements": null,
"state": "present",
"umask": null,
"version": null,
"virtualenv": "/usr/local/lib/docker/virtualenv",
"virtualenv_command": "virtualenv",
"virtualenv_python": "python3",
"virtualenv_site_packages": false
}
},
"item": {
"name": "docker-compose",
"path": "/usr/local/bin/docker-compose",
"src": "/usr/local/lib/docker/virtualenv/bin/docker-compose",
"state": "present",
"version": ""
},
"msg": "Could not get output from /usr/local/bin/virtualenv --help: Traceback (most recent call last):\n File \"/usr/local/bin/virtualenv\", line 6, in <module>\n from virtualenv.__main__ import run_with_catch\nModuleNotFoundError: No module named 'virtualenv.__main__'; 'virtualenv' is not a package\n"
}
On the server:
$ python --version
Python 3.7.3
$ pip --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
$ pip uninstall virtualenv
Not uninstalling virtualenv at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'virtualenv'. No files were found to uninstall.
$ pip install virtualenv
Requirement already satisfied: virtualenv in /usr/lib/python3/dist-packages (15.1.0)
$ virtualenv
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 6, in <module>
from virtualenv.__main__ import run_with_catch
ModuleNotFoundError: No module named 'virtualenv.__main__'; 'virtualenv' is not a package
from ansible-docker.
I ran sudo pip install --force virtualenv
manually on the target server and it solved the problem
from ansible-docker.
What OS and version are you using?
from ansible-docker.
Debian 10.10
from ansible-docker.
Was anything already installed on the server before you installed this role? Or more specifically do you recall messing around with any Python related packages?
from ansible-docker.
Luckily I used ansible to install any packages, when installing Debian I installed SSH and System Utilities from the install prompt, and these are the packages I install before running your role:
packages:
- sudo
- git
- vim
- zsh
- open-vm-tools
- ufw
- curl
from ansible-docker.
Hmm I can't reproduce this here on Debian 10. Did you run this playbook as the root user? You should be btw.
from ansible-docker.
That's weird, I will try to reproduce the problem in a new VM and document the bug better if I still encounter it, and yes It's running as root.
Thanks for the help!
from ansible-docker.
I did try a new virtual machine, it worked fine, I guess the problem wash the python version so when I changed it in Ansible it solved the problem, thanks!
from ansible-docker.
Happy to hear it worked. Going to close this as it seems resolved. Feel free to comment here if you can pin point exactly what happened in the future where it's something this role should be modified to fix or provide more clear documentation.
from ansible-docker.
Related Issues (20)
- Support for docker.io package (in addition to ce and ee) HOT 4
- Failed : Install Docker's dependencies HOT 9
- Package dependency error for Docker installation on clean Ubuntu 18.04 HOT 11
- Ubuntu 20.04 ImportError: No module named pkg_resources HOT 10
- Avoid docker login issue with X11 HOT 11
- Expected behavior for DockerHub private repositories login options? HOT 19
- Failed to import the required Python library HOT 10
- Update apt cache before installing packages HOT 1
- Add way to add additional packages to install HOT 3
- Versioning pinning not working HOT 5
- Hi; Please consider suppressing credentials output in: Manage Docker registry login credentials HOT 8
- Upgrade edge case HOT 9
- I'm thinking about no longer setting up a virtualenv, pip installing docker / docker compose and switching the docker_login module to a shell script HOT 2
- docker not installed into /usr/local/bin HOT 4
- Unable to find pip in the virtualenv HOT 8
- Error in new v2.2.0 version when using ansible 2.9.14 HOT 3
- Docker Compose V1 causes the Install Python packages step to crash HOT 3
- Error with pip on basic usage HOT 2
- Task exception at: Install Python packages HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-docker.