2017-06-20 19 views
0

enter image description here我正在关注Mining社交媒体第2版的书籍,在Twitter上做一些数据科学。我下载了包含必要文件和文件夹等的文件...... 在试图流浪时(它使用Vagrant来控制一个ipython笔记本将被执行的VM(一个virtualBox虚拟机)),我想出了一个奇怪的错误:NoNameError :未初始化的常数厨师::资源:: PythonPip 这里是default.tb文件: 默认[ '蟒'] [ 'INSTALL_METHOD'] = '包'NameError:未初始化的常量Chef :: Resource :: PythonPip

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' 

这里是/部署/蟒/提供者/ 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 

回答

0

python食谱明显标记为已弃用,并且根本不支持厨师13(或者只是一般,但我不会为厨师13修复它)。改为使用poise-python

+0

你能告诉我,我该怎么办?用poise-python替换python文件夹(从Git)?我认为它可能是一个“弃用的东西”,但我没有发现问题 –

+0

如果你刚开始与厨师,我建议通过learn.chef.io教程。 poise-python升级不是替代品,但它很接近。在poise-python自述文件中有一个升级指南。 – coderanger

+0

其实它告诉我,当我试图流浪了一个奇怪的错误:缺少Cookbooks:默认:无法满足版本限制:python可能有升级问题,文件自述可以帮助我?因为我没有足够的时间跟随教程并搜索它 –

1

更改为poise-python是最好的解决方案,但可以修补旧的python食谱。了解为什么这个错误发生可能帮助其他人在他们的定制食谱类似的问题,因为它们移动到厨师13

厨师13不再创建自定义资源模块常量在发布说明指出https://discourse.chef.io/t/chef-client-13-released/10735

只有两行代码中的折旧蟒蛇食谱需要改变,从而与厨师工作13

在供应商/ virtualenv.rb:

- @current_resource = Chef::Resource::PythonVirtualenv.new(new_resource.name) 
+ @current_resource = Chef::Resource.resource_for_node(:python_virtualenv, node).new(new_resource.name) 

在供应商/ pip.rb:

- @current_resource = Chef::Resource::PythonPip.new(new_resource.name) 
+ @current_resource = ::Chef::Resource.resource_for_node(:python_pip, node).new(new_resource.name) 
相关问题