Installs the Python language runtime

Counsyl, Inc.



4,202 latest version

3.8 quality score

Version information

  • 0.9.10 (latest)
  • 0.9.9
  • 0.9.8
  • 0.9.7
  • 0.9.6
  • 0.9.5
  • 0.9.4
  • 0.9.3
released Jul 7th 2018

Start using this module


counsyl/python — version 0.9.10 Jul 7th 2018


This Puppet module installs the Python language runtime, and provides classes for common Python packages and tools. In addition, an improved pip package provider (pipx) is included as well as custom types for Python virtual environments (venv) and packages inside virtual environments (venv_package).

By default, including the python class installs Python, setuptools, and pip; the python::virtualenv class installs virtualenv. Thus, to have Python, pip, and virtualenv installed on your system simply place the following in your Puppet manifest:

include python
include python::virtualenv

This module supports Debian, RedHat, OpenBSD, Solaris, Windows, and Darwin platforms -- Windows users should read the Windows Notes.

Python Classes


Installs Python, setuptools, and pip using the system packages for the platform, when available. If the system packages are too old, you may bootstrap setuptools and pip using the built-in template, e.g.:

class { 'python':
  ez_setup => true,


Installs virtualenv, using the default system package. If the system package is too old for your taste, tell it to be installed using pip by setting the package parameter to false:

include python
class { 'python::virtualenv':
  package => false,


Installs the Python development headers package for the system, useful when you need to install packages with C extensions with pip. For example, to install PyCrypto you could use the following (assuming a non-Windows platform):

include python
include python::devel

package { 'pycrypto':
  ensure   => installed,
  provider => 'pip',
  require  => Class['python::devel'],


Installs Django in the system site-packages using pip.

include python
include python::django


Installs Flask in the system site-packages using pip, for example:

include python
include python::flask


Installs requests in the system site-packages using pip, for example:

include python
include python::requests

Python Types


The pipx package provider is an enhanced version of Puppet's own pip provider, specifically it:

  • Implements the install_options feature, where you may specify the pip install options.
  • Uses HTTPS to query PyPI when setting ensure to 'latest'
  • Contains improvements for installing packages from version control

For example, assuming you had an internal PyPI mirror at, you could install the requests package system-wide from your mirror using the following:

package { 'requests':
  ensure          => installed,
  provider        => 'pipx',
  install_options => [
    { '--index-url' => '' },


The venv type enables the management of Python virtual environments. The name of the venv resource is the path to the virtual environment -- for example to have your virtualenv in /srv/venv, you'd use:

# Python and virtualenv are required to use `venv` type.
include python
include python::virtualenv

# Creating a virtualenv in /srv/venv.
venv { '/srv/venv': }

To have the virtualenv be owned by a user other than the one running Puppet (typically root), you can set the owner and group parameters (these are not supported on Windows):

venv { '/srv/venv':
  owner => 'justin',
  group => 'users',

When using the owner parameter Puppet will cast itself as this user when installing packages with venv_package -- this improves security especially when playing with unknown packages.

To have the virtualenv include the system site packages:

venv { '/srv/venv':
  system_site_packages => true,

To delete the virtualenv from the system:

venv { '/srv/venv':
  ensure => absent,


This type installs packages in a Python virtual environment -- the title of a venv_package resource must contain the name of the package and the path to to the virtual environment separated by the @ symbol. For example, to install Django into the venv defined above:

venv_package { 'Django@/srv/venv':
  ensure => installed,

The venv specifed after the @ will be automatically required. Like the pipx package provider, you may also specify install_options, e.g.:

venv_package { 'Flask@/srv/venv':
  ensure          => installed,
  install_options => [ { '--index-url' => '' } ],

Just like with Puppet's own pip provider, you can install using VCS -- for example, to install Flask from GitHub (at the 0.8.1 version tag):

include sys::git

venv_package { 'Flask@/srv/venv':
  ensure  => '0.8.1',
  source  => 'git+',
  require => Class['sys::git'],

Note: This had to be its own type (rather than a package provider) due to the fact that there can be multiple packages on a system in different virtual environments.

Windows Notes

Windows support requires the counsyl-windows module. Because %Path% updates aren't reflected in Puppet's current session, you will see errors about not being able to find the pip and/or virtualenv commands -- running Puppet again should make these errors go away on a fresh system. In addition, due to the nature of Windows platforms, customizations should be done on the python::windows class before including python. For example, to force the use the 32-bit version of Python 2.6.6 you would use the following:

class { 'python::windows':
  arch    => 'i386',
  version => '2.6.6',
include python


Apache License, Version 2.0


Justin Bronn


Please log tickets and issues at