//备份原source文件
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
//编辑
$ sudo gedit /etc/apt/sources.list
使用下列的其中一个源代替原内容便可:
阿里云:
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
清华源:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
再执行这条指令就换源成功:
$ sudo apt-get update
// 安装源
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
//或者中国源 与上一条二选一
$ sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
//设置key
$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
//更新 必需操作
$ sudo apt-get update
//安装 换源之后我用了20min
$ sudo apt-get install ros-kinetic-desktop-full
//解决依赖
$ sudo rosdep init
$ rosdep update
//环境配置
$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
如果没有遇见问题下面的就不用看啦
$sudo apt-get update
(appstreamcli:6499): GLib-CRITICAL **: g_strchug: assertion 'string != NULL' failed
(appstreamcli:6499): GLib-CRITICAL **: g_strchomp: assertion 'string != NULL' failed
(appstreamcli:6499): GLib-CRITICAL **: g_strchug: assertion 'string != NULL' failed
(appstreamcli:6499): GLib-CRITICAL **: g_strchomp: assertion 'string != NULL' failed
(appstreamcli:6499): GLib-CRITICAL **: g_strchug: assertion 'string != NULL' failed
(appstreamcli:6499): GLib-CRITICAL **: g_strchomp: assertion 'string != NULL' failed
AppStream cache update completed, but some metadata was ignored due to errors.
正在读取软件包列表... 完成
原因这个网站解释的很清楚:https://askubuntu.com/questions/854168/how-i-can-fix-appstream-cache-update-completed-but-some-metadata-was-ignored-d
//安装AppStream
$ sudo apt install appstream/xenial-backports
//查看AppStream版本,我对应的是 0.10.6
$ appstreamcli --version
//缓存更新
$ sudo appstreamcli refresh --force
再执行update不再报错
$ sudo apt-get install ros-kinetic-desktop-full
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:
下列软件包有未满足的依赖关系:
ros-kinetic-desktop-full : 依赖: ros-kinetic-desktop 但是它将不会被安装
依赖: ros-kinetic-perception 但是它将不会被安装
依赖: ros-kinetic-simulators 但是它将不会被安装
依赖: ros-kinetic-urdf-tutorial 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
使用aptitude进行安装,aptitude 会对依赖关系进行智能处理
$ sudo apt-get install aptitude
$ sudo aptitude install ros-kinetic-desktop-full
$ sudo rosdep init
sudo: rosdep:找不到命令
//maybe python-rosdep也可
$ sudo apt install python-rosdep2
再执行的输出结果如下,初始化成功:
$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
('The read operation timed out',)
网速问题,用个手机热点,多试几次
我觉得我装了一个假的ubuntu,运行哪一条指令都会报错
后来证实确实没装好ubuntu,一定要注意自己的电脑是UEFI还是Legacy。一般来说都是前者,就不要自己改了,在安装ubuntu进入u盘启动时从UEFI模式进入。
重装了一遍后,基本流程没有一条指令报错。。。就当涨经验了。。。
参考教程:https://www.cnblogs.com/wdzeng/p/10275439.html
~/turtlebot$ wstool init -j4 src https://raw.github.com/yujinrobot/yujin_tools/kinetic-devel/rosinstalls/kinetic/turtlebot.rosinstall
Using initial elements from: https://raw.github.com/yujinrobot/yujin_tools/kinetic-devel/rosinstalls/kinetic/turtlebot.rosinstall
ERROR in config: Unable to download URL [https://raw.github.com/yujinrobot/yujin_tools/kinetic-devel/rosinstalls/kinetic/turtlebot.rosinstall]:
问题原因是:未能解析目标网站的DNS服务器
解决方案:添加DNS服务器配置信息
//打开配置文件
sudo gedit /etc/resolv.con
修改文件内容如下,其中114.114.114.114是国内移动、电信和联通通用的DNS。8.8.8.8是GOOGLE公司提供的DNS,该地址全球通用。
#nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 114.114.114.114
~/turtlebot$ rosdep install --from-paths src -i -y
executing command [sudo -H apt-get install -y ros-kinetic-stdr-resources]
E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
ERROR: the following rosdeps failed to install
apt: command [sudo -H apt-get install -y ros-kinetic-stdr-resources] failed
原因:我在执行rosdep install --from-paths src -i -y命令时将该进程强行关闭,但是进程并没有结束,再次运行报错。
即有另一个程序正在占用进程,由于它在运行时,会占用软件源更新时的系统锁(简称‘系统更新锁’),此时资源被锁。我们只需要杀死之前的进程,释放系统锁便可。
//查看进程对应id
ps -e|grep 进程名
//杀死该进程
sudo kill 进程id
但由于我不太清楚该命令对应进程名为何,所以转战第二个方案。
强制解锁
$ sudo rm /var/cache/apt/archives/lock
$ sudo rm /var/lib/dpkg/lock
但是强制解锁失败,我干脆重启计算机了。。。