Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So here's a snippet from my manifest (based on this module:

python::virtualenv { $virtualenv_dir:
ensure => present,
version => 'system',
systempkgs => false,
distribute => false,
owner => $user,
group => $group,

That works fine when I run puppet apply for the first time. Second time it fails though:

Already using interpreter /usr/bin/python
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 3, in 
File "/usr/lib/python2.7/dist-packages/", line 938, in main
File "/usr/lib/python2.7/dist-packages/", line 1039, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/lib/python2.7/dist-packages/", line 1274, in install_python
shutil.copyfile(executable, py_executable)
File "/usr/lib/python2.7/", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 26] Text file busy: '/usr/local/myapp/venv/bin/python'

This is probably because I have a bunch of background processes running that using the Python binary from virtualenv (Celery workers, uwsgi workers etc).

Is there a way to only init the virtualenv first time? There is no need to run virtualenv command once the directory is created, right?

share|improve this question
Could this be related to the 'Fix path for unless statement' commit (Jan 1, 2014)? Looking at the code, that may have something to do with this type of issue. There are several other updates recently so you might look into updating the module. – jdkindy Jan 7 '14 at 14:37

The following class will create a virtual env. "creates" limits the command to only be run if the virtualenv doesn't exist

class virtualenv ( $virtualenv_dir ) {
    ensure => installed,

    creates => $virtualenv_dir,
    command => "virtualenv $virtualen_dir",
    require => Package['python-virtualenv'],

Call the class with the following:

class {'virtualenv':
  virtualenv_dir => '/path/to/virtualenv',
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.