【发布时间】:2017-11-22 09:46:03
【问题描述】:
我正在关注《挖掘社交媒体》第 2 版一书,以便在 Twitter 上做一些数据科学。我下载了包含必要文件和文件夹等的文件...... 在尝试流浪时(它使用 Vagrant 来控制将执行一些 ipython 笔记本的 VM(virtualBox vm)),我发现了一个奇怪的错误: NoNameError: uninitialized constant Chef::Resource::PythonPip 这是 default.tb 文件: 默认['python']['install_method'] = 'package'
if node['python']['install_method'] == 'package'
case node['platform']
when "smartos"
default['python']['prefix_dir'] = '/opt/local'
else
default['python']['prefix_dir'] = '/usr'
end
else
default['python']['prefix_dir'] = '/usr/local'
end
default['python']['binary'] = "#{node['python']
['prefix_dir']}/bin/python"
default['python']['url'] = 'http://www.python.org/ftp/python'
default['python']['version'] = '2.7.7'
default['python']['checksum'] =
'3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059'
default['python']['configure_options'] = %W{--prefix=#{node['python']
['prefix_dir']}}
default['python']['setuptools_script_url'] =
'https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py'
default['python']['pip_script_url'] = 'https://bootstrap.pypa.io/get-
pip.py'
这里是 /deploy/python/providers/pip.rb(它识别出错误的地方)
require 'chef/mixin/shell_out'
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
def whyrun_supported?
true
end
# the logic in all action methods mirror that of
# the Chef::Provider::Package which will make
# refactoring into core chef easy
action :install do
# If we specified a version, and it's not the current version, move
to the specified version
if new_resource.version != nil && new_resource.version !=
current_resource.version
install_version = new_resource.version
# If it's not installed at all, install it
elsif current_resource.version == nil
install_version = candidate_version
end
if install_version
description = "install package #{new_resource} version #
{install_version}"
converge_by(description) do
Chef::Log.info("Installing #{new_resource} version #
{install_version}")
status = install_package(install_version)
if status
new_resource.updated_by_last_action(true)
end
end
end
end
action :upgrade do
if current_resource.version != candidate_version
orig_version = current_resource.version || "uninstalled"
description = "upgrade #{current_resource} version from #
{current_resource.version} to #{candidate_version}"
converge_by(description) do
Chef::Log.info("Upgrading #{new_resource} version from #
{orig_version} to #{candidate_version}")
status = upgrade_package(candidate_version)
if status
new_resource.updated_by_last_action(true)
end
end
end
end
action :remove do
if removing_package?
description = "remove package #{new_resource}"
converge_by(description) do
Chef::Log.info("Removing #{new_resource}")
remove_package(new_resource.version)
new_resource.updated_by_last_action(true)
end
【问题讨论】:
标签: python ruby pip chef-infra