I am using ansible against Ubuntu 16.04 .
The ultimate goal is to use mongodb_user
module.
This requires pymongo
, so this require python-pip
- name: Package prerequisites for pymongo ansible module
apt:
force_apt_get: yes
name: ['python-pip', 'python-setuptools']
install_recommends: no
state: present
become: true
tags:
- mongo
register: output
- name: Upgrade pip to latest vesion
pip:
name: pip
extra_args: --upgrade
register: output
- debug:
var: output
This is actual output; please note:
pip
ignores upgrade instructions /usr/bin/pip2
binary , while I was expecte "output": {
"changed": true,
"cmd": [
"/usr/bin/pip2",
"install",
"--upgrade",
"pip"
],
"failed": false,
"name": [
"pip"
],
"requirements": null,
"state": "present",
"stderr": "You are using pip version 8.1.1, however version 18.1 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n",
"stderr_lines": [
"You are using pip version 8.1.1, however version 18.1 is available.",
"You should consider upgrading via the 'pip install --upgrade pip' command."
],
"stdout": "Collecting pip\n Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl\nInstalling collected packages: pip\nSuccessfully installed pip-8.1.1\n",
"stdout_lines": [
"Collecting pip",
" Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl",
"Installing collected packages: pip",
"Successfully installed pip-8.1.1"
],
"version": null,
"virtualenv": null
}
The strange thing is that, from command line I got
$ /usr/bin/pip2 -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$ /home/mirko/.local/bin/pip -V
pip 18.1 from /home/mirko/.local/lib/python2.7/site-packages/pip (python 2.7)
I tried to manually upgrade pip after install of python-pip
and got another strange thing: pip do not want to uninstall old pip...
sudo pip install pip --upgrade
[sudo] password for mirko:
The directory '/home/mirko/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mirko/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 1.2MB/s
Installing collected packages: pip
Found existing installation: pip 8.1.1
Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
What is the right way to use pip with ansible vs an Ubuntu 16.04?
Must/Can I force ansible to use "my" pip?
Must/Can I deinstall the "wrong" pip?
Have I done something wrong to create this dual-version problem?
env: Ubuntu 18.04, Python 3.6.9, pip originally at 9.0.1
.
I ended up doing the following:
- name: pip self-update
pip:
name: pip
state: latest
see doc about pip module
and I did this, all on its own, before running a pip requirements install. There were so many failures on the install, and pip was so old that I wanted to make extra sure before I went anywhere close to other installs.
This brought me up to pip 20.0.2 or so.
Larger context: I did specify a virtualenv and I also set ansible_python_interpreter="/usr/bin/python3"
via an inventory file.
virtualenv: "/srv/venv"
You may or may not need to do those things, the important part is making 200% sure pip is reasonably current.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With