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

I'm using Opscode's application_python cookbook, and trying to deploy a Django application. I need to use Python 2.7 for this project, but it appears that the virtualenv creation is done with python2.6 by default, which I don't plan on installing on the system. Therefore, I get the following error when running chef-client:

[Fri, 08 Jun 2012 16:55:35 +0000] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env] (/var/chef/cache/cookbooks/python/providers/virtualenv.rb line 28) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '3'
---- Begin output of virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env ----
STDOUT: The executable python2.6 (from --python=python2.6) does not exist
---- End output of virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env ----
Ran virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env returned 3

I'm pretty (extremely) new to Chef, and haven't got an idea of how to change it. The default seems to be set with attribute :interpreter, :default => 'python2.6' in cookbooks/python/resources/virtualenv.rb. I've tried setting defaults both on my node and in the environment as the following, with no success:

  "python" => {
    "virtualenv" => {
      "interpreter" => "python2.7"

I'm sure this is configurable, but I can't figure out quite how to do it. What am I setting incorrectly?

share|improve this question
up vote 0 down vote accepted

I always create my virtualenv in my deployment recipes explicitly, and then reference that virtualenv as needed. For example:

venv_dir = node['some_identifier']['virtualenv_dir']

python_virtualenv venv_dir do
    interpreter "python"            # use system default python, not 2.6
    action :create

python_pip "django" do
    version "1.4"
    action :install
    virtualenv venv_dir

Obviously, this is using the python_virtualenv resource out of the python cookbook, so the python cookbook will need to be listed as a dependency within your cookbook.

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.