Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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
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.

share|improve this answer

Your Answer

 
discard

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.