下载包时,流浪木偶会被卡住

时间:2017-03-07 22:13:44

标签: python-2.7 vagrant pip puppet

试图让流浪汉跑起我的测试环境,但是当我尝试启动时,我收到了这个错误:

==> default: Running provisioner: puppet...
==> default: Running Puppet with base.pp...
==> default: notice: Scope(Class[Sandbox]): Setting up sandbox box
==> default: notice: /Stage[main]//Exec[update_apt]/returns: executed successfully
==> default: notice: /Stage[main]/sandbox/Package[http://pypi.python.org/packages/source/h/hurry.filesize/hurry.filesize-0.9.tar.gz]/ensure: created
==> default: err: /Stage[main]/sandbox/Exec[update_pip]/returns: change from notrun to 0 failed: Could not find command '/usr/bin/pip'
==> default: err: /Stage[main]/sandbox/Exec[update_python_packages]/returns: change from notrun to 0 failed: Could not find command '/usr/bin/pip'
==> default: notice: Finished catalog run in 5.94 seconds

现在我认为主要问题在于:

==> default: err: /Stage[main]/sandbox/Exec[update_pip]/returns: change from notrun to 0 failed: Could not find command '/usr/bin/pip'
==> default: err: /Stage[main]/sandbox/Exec[update_python_packages]/returns: change from notrun to 0 failed: Could not find command '/usr/bin/pip'

我将其追溯到我的base.pp文件。我认为问题出在这里。

 95   exec { "update_pip":
 96     command => "/usr/bin/pip install --upgrade pip",
 97   }
 98 
 99   exec { "update_python_packages":
100     command => "/usr/bin/pip install -r /vagrant/requirements.txt",
101   }

如果说我不能使用" / usr / bin / pip,我该如何安装pip。" ?

我对流浪汉很陌生,所以如果我不知道任何事情,请告诉我。谢谢。

2 个答案:

答案 0 :(得分:1)

您应该使用this module来处理Python及所有相关内容的安装。在Puppet中执行登录可能非常困难,所以让一些完善的模块来处理它几乎总是更好。

这个简单的资源可以确保您的路径中将安装和使用pip。

class { 'python' :
  version    => 'system',
  pip        => 'present',
  dev        => 'absent',
  virtualenv => 'absent',
  gunicorn   => 'absent',

}

由于我链接的Puppet模块,您甚至可以告诉Puppet创建virtualenv并在某个目录中运行pip install -r requirements

如果您不想使用外部模块,我建议您登录Vagrant机器并仔细检查pip是否已安装且可用。您可以运行which pip以查看需要指定用于在exec资源中运行pip的确切路径。

答案 1 :(得分:0)

这是我最终绕过一切的方式:

新代码:

 90   exec { "update_pip":
 91     command => "/usr/bin/env pip install --upgrade pip",
 92   }
 93   exec { "update_python_packages":
 94     command => "/usr/bin/env pip install -r /vagrant/requirements.txt",
 95   }

原始代码

 98
 99 #  exec { "update_pip":
100 #    command => "/usr/bin/pip install --upgrade pip",
101 #  }
102 #
103 #  exec { "update_python_packages":
104 #    command => "/usr/bin/pip install -r /vagrant/requirements.txt",
105 #  }

我注意到的是,它无法找到/ usr / bin / pip,所以我使用了env标志,我认为这意味着无论安装在哪里都会升级。这解决了这个问题。