Manage Windows like Linux with Ansible?

Please try

python -m pip install --upgrade pip

Can’t you use python3?

python3 pip install --upgrade pip

After this I have no more ideas. Perhaps @mrmarkuz can help.

Thank you! Lets see…

This should work but changes the systems python3.

If possible use a venv, this way systems python stays untouched and only pip in the virtual environment is updated.

# Create venv
python3 -m venv /opt/ansible
# Enter venv
source /opt/ansible/bin/activate

Example of updating pip in a virtualenv:

[root@testserver ~]# python -V
Python 2.7.5

[root@testserver ~]# python3 -V
Python 3.6.8

[root@testserver ~]# python3 -m pip -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

[root@testserver ~]# source /opt/ansible/bin/activate
(ansible) [root@testserver ~]# python -V
Python 3.6.8

(ansible) [root@testserver ~]# pip -V
pip 9.0.3 from /opt/ansible/lib64/python3.6/site-packages (python 3.6)

(ansible) [root@testserver ~]# pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/ca/31/b88ef447d595963c01060998cb329251648acf4a067721b0452c45527eb8/pip-21.2.4-py3-none-any.whl (1.6MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1.6MB 885kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
Successfully installed pip-21.2.4

(ansible) [root@testserver ~]# pip -V
pip 21.2.4 from /opt/ansible/lib64/python3.6/site-packages/pip (python 3.6)

Another way is to use Software Collections to use more recent versions of python. @stephdl provides different scl python versions with additional options.

Here is an example of using rh-python38:

yum -y install rh-python38
scl enable rh-python38 bash

# create virtual environment
python -m venv /opt/ansible

# enter virtual environment
source /opt/ansible/bin/activate
pip install --upgrade pip

Another example: Matrix-synapse uses rh-python36.

1 Like

Hi Markus, this went well:

But if I try to install pip install pywinrm[Kerberos] I get the next error:

I thought a higher version of python is needed but in the howto you posted Python 2.7 is used. Only the pip upgrade does not work, it’s just a warning and can be ignored.
The installation of pywinrm for kerberos works.

yum -y install python-devel krb5-devel krb5-libs krb5-workstation python-pip bind-utils ansible
pip install pywinrm[Kerberos]
1 Like