我正在使用 hashcorp/precise64。 (我在 ubuntu/trusty64 和很多其他盒子上也遇到了同样的错误。)
尝试使用以下代码进行配置,但出现错误。
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y python-pip python-dev python-setuptools build-essential
sudo pip install numpy
SHELL
==> 默认:sudo ==> 默认: : ==> 默认:pip:找不到命令
在 ssh 进入虚拟机并尝试调用 pip 后,我得到了
vagrant@precise64:$ pip 当前未安装程序“pip”。 您可以通过输入以下命令来安装它: sudo apt-get install python-pip
如果我这样做
sudo apt-get install python-pip
,pip确实会被安装。
我不明白为什么不能通过shell安装。
我想也许这与将安装暴露到某些路径有关?
重新开始(删除流浪盒和实例)并为两个
-y
添加sudo apt-get update;sudo apt-get upgrade
标志解决了问题。
我在没有
-y
标志的情况下执行了“sudo apt-get update;sudo apt-get Upgrade”,但出现了问题。
虽然我仍然不明白为什么
sudo apt-get install xxx
可以通过ssh工作而不必sudo apt-get -y update;sudo apt-get -y upgrade
我可以使用以下 Vagrantfile(Ubuntu 23.04 guest 虚拟机)重现该问题:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Site = "crbienes"
Box = Site + "-test"
Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for boxes at https://vagrantcloud.com/search.
config.vm.box = "vasilli/Ubuntu-23.04-LAMP"
config.vm.define Box
config.vm.hostname = Box
config.vm.network "private_network", ip: "192.168.70.11"
config.vm.provider "virtualbox" do |vb|
vb.name = Box
end
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y python-pip python-dev python-setuptools build-essential
sudo pip install numpy
SHELL
end
我收到此错误:
crbienes-test: Package python-dev is not available, but is referred to by another package.
crbienes-test: This may mean that the package is missing, has been obsoleted, or
crbienes-test: is only available from another source
crbienes-test: However the following packages replace it:
crbienes-test: python-dev-is-python3
crbienes-test:
crbienes-test: Package python-setuptools is not available, but is referred to by another package.
crbienes-test: This may mean that the package is missing, has been obsoleted, or
crbienes-test: is only available from another source
crbienes-test:
crbienes-test: Package python-pip is not available, but is referred to by another package.
crbienes-test: This may mean that the package is missing, has been obsoleted, or
crbienes-test: is only available from another source
crbienes-test: However the following packages replace it:
crbienes-test: python3-pip
如果我通过 SSH 连接到来宾,我会收到完全相同的错误,所以这很好,一致。 我可以通过 apt install 安装 python-dev-is-python3 和 python3-pip 。当我尝试安装 build-essential 时,我收到一条警告,指出我已经拥有最新版本。但它仍然有效(如尝试安装)。我无法安装/找到 python-setuptools。似乎它已被弃用。您应该寻找替代方案。
这是您的新 Vagrantfile。我删除了 'sudo' b/c shell 脚本默认以 sudo 运行,您不需要显式指定它。:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Site = "crbienes"
Box = Site + "-test"
Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for boxes at https://vagrantcloud.com/search.
config.vm.box = "vasilli/Ubuntu-23.04-LAMP"
config.vm.define Box
config.vm.hostname = Box
config.vm.network "private_network", ip: "192.168.70.11"
config.vm.provider "virtualbox" do |vb|
vb.name = Box
vb.linked_clone = true # saves time/space by not copying the box
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y python3-pip python-dev-is-python3 build-essential
pip install numpy # this gives me an error, you should investigate
SHELL
end