pip module doing incomplete installation on Raspberry Pi

I’m seeing a funny behavior when using Ansible to manage an installation on a Raspberry Pi running Raspbian Jessie lite.

The playbook includes the following, to install a Python program called ‘power-cycle’ from a GitHub repo:

  • hosts: power_controllers
    tasks:
  • name: Install the power cycle utility
    pip: name=‘git+http://github.com/burlington-arc/power-cycle.git#egg=power-cycle’

After running the playbook, the ‘power-cycle’ command is available and works fine. However, if I run it after a reboot, it fails with a ‘distribution not found’:

pi@barcpi004:~ $ power-cycle
Traceback (most recent call last):
File “/usr/local/bin/power-cycle”, line 5, in
from pkg_resources import load_entry_point
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2876, in
working_set = WorkingSet._build_master()
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 449, in _build_master
ws.require(requires)
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 745, in require
needed = self.resolve(parse_requirements(requirements))
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 639, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: power-cycle==1.0.2

In other words, the installation with ‘pip’ didn’t survive a reboot.

If I install the same egg from the command line, it all works fine and survives the reboot.

It appears that the pip module is doing some kind of incomplete or perhaps temporary installation. After the playbook has run, the ‘/usr/local/lib/python2.7/dist-packages/’ dir looks like this:

pi@barcpi004:~ $ ls /usr/local/lib/python2.7/dist-packages/
daemon lockfile
docutils lockfile-0.12.2.dist-info
docutils-0.13.1.dist-info power-cycle.egg-link
easy-install.pth python_daemon-2.1.2.dist-info

…whereas, after running ‘sudo pip install git+http://github.com/burlington-arc/power-cycle.git#egg=power-cycle’ from the command line, it looks like:

pi@barcpi004:~ $ ls /usr/local/lib/python2.7/dist-packages/
daemon lockfile-0.12.2.dist-info
docutils power_cycle-1.0.2.egg-info
docutils-0.13.1.dist-info power-cycle.egg-link
easy-install.pth powerpi
lockfile python_daemon-2.1.2.dist-info

…which has a directory for ‘powerpi’, which has the required scripts in it.

Any ideas? Am I missing something with the ‘pip’ task?

Thanks in advance,

Greg

Forgot to mention - Ansible 2.2.1.0 on the control machine, pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7) on the Pi.

Found the answer:

The ‘pip’ module defaults to installing applications in ‘editable’ mode. Not sure why that doesn’t survive a reboot, but if I change the ansible script to:

  • hosts: power_controllers
    tasks:
  • name: Install the power cycle utility
    pip:
    name: ‘git+http://github.com/burlington-arc/power-cycle.git#egg=power-cycle’
    editable: false

…It works correctly, and the installation survives reboot.

Greg.