3 ms·
We had some software break earlier this week because our Ansible role installs Python 3.8.10 as `python` but the system had 3.8.6 installed as `python3`. This m
by danudey 5y ago
We had some software break earlier this week because our Ansible role installs Python 3.8.10 as `python` but the system had 3.8.6 installed as `python3`. This meant that when we ran `/usr/bin/env python` it used the non-system python which wasn't picking up packages from /usr/lib/python3.8/dist-packages or wherever Ubuntu packages are installed.
The default `pip` and `pip3` commands, however, used the system python and did read those directories, meaning that it kept insisting the given package was installed. It was a frustrating amount of digging around that could have been avoided in myriad ways, one of which being containers (though for a 30-line python script, docker seems like overkill).
- mejutoco 5y agoTo avoid this problem I use virtualenv for each project _and_ I point to the pip binary inside that env (env/bin/pip or env/bin/python) in my ansible scripts or any other commands. I settled on this after running into similar problems