A collection of task oriented solutions in Puppet

 

Could not locate command pip

Challenge

You want to install Python packages using pip but receive an error.

Solution

class installer {

  package { 'pySMART':
    ensure   => 'installed',
    provider => 'pip',
  }

}

But when puppet runs you see error messages similar to those below:

Error: Could not set 'present' on ensure:
  Could not locate command pip and pip-python.
  (file: /.../pip-install.pp, line: 3)

Could not locate command pip and pip-python.

Error: /Stage[main]/Installer/Package[pySMART]/ensure:
  change from 'absent' to 'present' failed:
  Could not set 'present' on ensure:
  Could not locate command pip and pip-python.
  (file: /.../pip-install.pp, line: 3)

Explanation

You are trying to manage Python packages from PyPi via the pip provider but you are receiving messages like these:

Error: Could not set 'present' on ensure:
  Could not locate command pip and pip-python.
  (file: /.../pip-install.pp, line: 3)

Could not locate command pip and pip-python.

Error: /Stage[main]/Installer/Package[pySMART]/ensure:
  change from 'absent' to 'present' failed:
  Could not set 'present' on ensure:
  Could not locate command pip and pip-python.
  (file: /.../pip-install.pp, line: 3)

These errors indicate that the Python packaging commands needed to enable the Puppet pip provider (try saying that quickly 10 times) are not present on the system. While you could fix this by installing them manually this is the Puppet Cookbook! Instead we'll use the stankevich-python module to ensure the dependencies are installed.

class manage-python {

  class { 'python': }

}

By default the module will ensure python and pip are installed on the system. Once these packages are present the provider can load successfully and begin to manage pip package resources.

See also