ubuntu16 安装ROS Kinetic:sudo rosdep init 和 rosdep update 报错
前段时间手贱重装了ubuntu16.04,在安装ROS的时候,sudo rosdep init 和 rosdep update 报错了,折腾了半天最终处理好了,把出坑经历记录下来:
报错信息如下:
$ sudo rosdep init
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
分析:由于无法打开上面网址中的文件,因此无法下载导致的错误
解决思路:
①、如果自己电脑能科学上网,那应该就能解决这个问题
②、按照下面方法逐个排查
方法一:(亲测有效)
从 https://github.com/ros/rosdistro/issues/9721 找到的办法,再我的电脑上成功解决了问题。
sudo apt-get install ca-cacert
sudo c_rehash /etc/ssl/certs
sudo update-ca-certificates
再次运行 就可以了
方法二:
ca-certificates问题,证书不对,重新安装证书
sudo apt-get install ca-certificates
方法三:
系统时间同步问题,需要同步系统时间
参照链接https://blog.csdn.net/A18373279153/article/details/81003937进行系统时间同步
sudo apt-get install ntpdate
sudo ntpdate cn.pool.ntp.org
sudo hwclock --systohc
方法四:
可能试ssl certs问题,继续尝试解决
sudo c_rehash /etc/ssl/certs
sudo -E rosdep init
方法五:
为自己电脑添加host(成功了一会,后来再试就不行了)
通过IPAddress.com首页,输入raw.githubusercontent.com查询到真实IP地址。然后修改hosts Ubuntu
sudo gedit /etc/hosts
添加以下内容保存即可
199.232.28.133 raw.githubusercontent.com
转(http://qjzd.net:3000/topic/5e48cc33dcf06d6a181ffb81)
然后重启电脑,输入sudo rosdep init就可以了
可能会出现下面的两种错误
报错内容一:
rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
(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)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
Failed to download target platform data for gbpdistro:
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
(https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
解决方法:
参考:https://zhuanlan.zhihu.com/p/77483614
ERROR是urlopen和ssl验证的问题。
报的错误原因是python 升级到 2.7.9 之后引入了一个新特性,当使用urllib.urlopen打开一个 https 链接时,会验证一次 SSL 证书,而当目标网站使用的是自签名的证书时就会抛出一个 urllib2.URLError的错误消息。因此,只能想办法在执行rosdep update时尝试定位urllib.urlopen()函数并规避掉SSL验证。
发现试在下面的文件中调用了这个函数:
/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
中的download_default_sources_list()调用了urlopen()
因此,在/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py中顶部直接插入两行代码取消SSL验证
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
再次运行 rosdep update 即可
报错内容二:
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
ERROR: error loading sources list:
('The read operation timed out',)
显示是时间超时,原因是网络的问题,需要现在使用的是WIFI的话,可以换成热点试一试。再运行的时候可能会失败,但是多多试几次,肯定会成功的!