1

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
STDERR: 
---- 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:

default_attributes(
  "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?

Brian Hicks
  • 185
  • 1
  • 8

1 Answers1

0

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
end 

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

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.

William McVey
  • 166
  • 1
  • 3