Sha256: 4a27d6d6742cb8a3c4cd1ef4182dbc56adf877f2ce7b9331e08a5f3af8ec6bbd

Contents?: true

Size: 1.66 KB

Versions: 20

Compression:

Stored size: 1.66 KB

Contents

---
title: About the pip Resource
platform: os
---

# pip

Use the `pip` InSpec audit resource to test packages that are installed using the Python PIP installer.

<br>

## Availability

### Installation

This resource is distributed along with InSpec itself. You can use it automatically.

### Version

This resource first became available in v1.0.0 of InSpec.

## Syntax

A `pip` resource block declares a package and (optionally) a package version:

    describe pip('package_name') do
      it { should be_installed }
    end

where

* `'package_name'` is the name of the package, such as `'Jinja2'`
* `be_installed` tests to see if the package described above is installed

<br>

## Examples

The following examples show how to use this InSpec audit resource.

### Test if Jinja2 is installed on the system

    describe pip('Jinja2') do
      it { should be_installed }
    end

### Test if Jinja2 2.8 is installed on the system

    describe pip('Jinja2') do
      it { should be_installed }
      its('version') { should eq '2.8' }
    end

### Test packages installed into a non-default location (e.g. virtualenv) by passing a custom path to pip executable

    describe pip('Jinja2', '/path/to/bin/pip') do
      it { should be_installed }
      its('version') { should eq '2.8' }
    end

<br>

## Matchers

For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).

### be_installed

The `be_installed` matcher tests if the named package is installed on the system:

    it { should be_installed }

### version

The `version` matcher tests if the named package version is on the system:

    its('version') { should eq '1.2.3' }

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
inspec-core-2.3.10 docs/resources/pip.md.erb
inspec-2.3.10 docs/resources/pip.md.erb
inspec-core-2.3.5 docs/resources/pip.md.erb
inspec-2.3.5 docs/resources/pip.md.erb
inspec-core-2.3.4 docs/resources/pip.md.erb
inspec-2.3.4 docs/resources/pip.md.erb
inspec-core-2.2.112 docs/resources/pip.md.erb
inspec-2.2.112 docs/resources/pip.md.erb
inspec-core-2.2.102 docs/resources/pip.md.erb
inspec-2.2.102 docs/resources/pip.md.erb
inspec-core-2.2.101 docs/resources/pip.md.erb
inspec-2.2.101 docs/resources/pip.md.erb
inspec-core-2.2.78 docs/resources/pip.md.erb
inspec-2.2.78 docs/resources/pip.md.erb
inspec-core-2.2.70 docs/resources/pip.md.erb
inspec-2.2.70 docs/resources/pip.md.erb
inspec-core-2.2.64 docs/resources/pip.md.erb
inspec-2.2.64 docs/resources/pip.md.erb
inspec-core-2.2.61 docs/resources/pip.md.erb
inspec-2.2.61 docs/resources/pip.md.erb