I was installing ansible on OpenSuSE Leap 42.3 machine and faced a problem with multiple python versions. I have both python 2.7 and python 3.4 installed on this machine. Python 2.7 is the default one.
I tried installed ansible with the usual pip install and was faced with an error related to setuptools (could not capture the error message). I upgraded my pip version to the latest one 10.0.1 and then installed ansible.
$ sudo pip install --upgrade pip $ sudo pip install ansible
After that I ran an ansible-galaxy init command to create one of the roles and I was welcome with the error stating “Error: Ansible requires a minimum of Python2 version 2.6 or Python3 version 3.5. Current version: 3.4.6”. And I was wondering what happened because my default python version was 2.7.
The usual google search did not help me go anywhere. So I looked at the /usr/bin/ansible file and found that it was using python3 interpreter.
$ head -1 /usr/bin/ansible #!/usr/bin/python3
I then checked the source of pip command and found the same thing.
$ head -1 /usr/bin/pip #!/usr/bin/python3
So I looked at pip documentation on installing pip for python 2.7 and found this link which helped me with the command to install pip for the default version of python installed –
$ sudo python -m ensurepip --default-pip Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages Collecting pip Installing collected packages: pip Successfully installed pip-9.0.1
Now when I reinstalled ansible, it installed the correct python interpreter for my system.
$ sudo pip install ansible Collecting ansible Cache entry deserialization failed, entry ignored ..... ..... You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. $ head -1 /usr/bin/pip /usr/bin/ansible ==> /usr/bin/pip <== #!/usr/bin/python ==> /usr/bin/ansible <== #!/usr/bin/python
Now when I upgraded pip it was for the default python version
$ sudo pip install --upgrade pip Collecting pip Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 9.0.1 Uninstalling pip-9.0.1: Successfully uninstalled pip-9.0.1 Successfully installed pip-10.0.1 $ head -1 /usr/bin/pip /usr/bin/ansible ==> /usr/bin/pip <== #!/usr/bin/python ==> /usr/bin/ansible <== #!/usr/bin/python</p>
In all probability all this was my fault and I think the pip which I upgraded in the beginning of this process may have been installed for python3 by me, otherwise I do not see any reason for all these issues.
Still I thought to share this entry, just in case someone can be helped.