我正在使用 Opscode应用程序_pythoncookbook,并尝试部署 Django 应用程序。我需要为这个项目使用 Python 2.7,但似乎python2.6
默认情况下会创建虚拟环境,我不打算在系统上安装它。因此,运行时出现以下错误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
我对 Chef 还很陌生,不知道如何更改它。默认值似乎是用attribute :interpreter, :default => 'python2.6'
in设置的cookbooks/python/resources/virtualenv.rb
。我尝试在我的节点和环境中设置默认值,如下所示,但没有成功:
default_attributes(
"python" => {
"virtualenv" => {
"interpreter" => "python2.7"
}
}
)
我确信这是可配置的,但我不知道该怎么做。我哪里设置错了?
答案1
我总是在部署方案中明确创建虚拟环境,然后根据需要引用该虚拟环境。例如:
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
显然,这是使用python_virtualenv
Python Cookbook 中的资源,因此 Python Cookbook 需要作为 Cookbook 中的依赖项列出。