pdf签名无效解决办法_ROS:sudo rosdep init出错常规方法都无效后解决办法记录

参照网上进行ubuntu16.04系统下ROS平台安装时(例如Ubuntu16.04下的ROS安装),在初始化rosdep时报错,20-default.list无法下载:

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.

google查找了很多解决办法(例如rosdep init gives "Website may be down." · Issue #9721 · ros/rosdistro),网上典型热门解决方法如下:

1)ca-certificates问题,证书不对,重新安装证书

sudo apt-get install ca-certificates

2)系统时间同步问题,需要同步系统时间

参照链接https://blog.csdn.net/A18373279153/article/details/81003937进行系统时间同步

sudo apt-get install ntpdate
sudo ntpdate cn.pool.ntp.org
sudo hwclock --systohc

3) 还是ssl certs问题,继续尝试解决

sudo c_rehash /etc/ssl/certs 
sudo -E rosdep init

4)python-rosdep问题

sudo apt-get install python-rosdep

但以上方法全部无效,无奈之下直接在/etc目录下新建/ros/rosdep/sources.list.d/20-default.list文件(注意sudo rosdep init失败时,/etc下并没有/ros目录,需要依次逐级新建),然后将https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list内容粘贴进去,如下:

# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

至此,终于解决了20-default.list下载不下来的问题。

注:这里虽然手动新建了20-default.list,但执行sudo rosdep init依然会出现之前的错误,这里我们无视,继续执行下一步。

2.接下来要进行升级,可惜还是报错:

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]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (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]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (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]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (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]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (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:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
	<urlopen error <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>

2020-09-16最近更新:最近又开始弄ROS,

对于rosdep update的报错,尝试了评论区的方法,发现挺好用,特此记录,多谢评论区提醒,下面是老方法和新方法:

方法一(新方法,推荐)

#打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133  raw.githubusercontent.com
#保存后退出再尝试
rosdep update

方法二(老方法,更复杂)

看ERROR是urlopen和ssl验证的问题,虽然已经可以读取我们手动新建的20-default.list中的内容,但并没有解决根本问题,要下载东西时依然出错。

报的错误原因是python 升级到 2.7.9 之后引入了一个新特性,当使用urllib.urlopen打开一个 https 链接时,会验证一次 SSL 证书,而当目标网站使用的是自签名的证书时就会抛出一个 urllib2.URLError的错误消息。

既然前面尝试了很多办法都没法解决SSL验证问题,那只能想办法在执行rosdep update时尝试定位urllib.urlopen()函数并规避掉SSL验证。

搜了很久,终于找到Z-HE:sudo rosdep init出错的解决方案,定位rosdep命令中用到的urllib.urlopen()

rosdep命令是py脚本,入口:
查找rosdep地址: /usr/bin/rosdep
查看rosdep.py内容:from rosdep2.main import rosdep_main
查找rosdep2地址:/usr/lib/python2.7/dist-packages/rosdep2
从main.py中进一步定位,发现是在
/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py中的
download_default_sources_list()调用了urlopen()

找到urlopen()之后,如果参考链接里的解决方案,需要修改所有调用的14个地方,太复杂。如果我们可以在rosdep浅入口处设置urlopen()全局属性,取消SSL验证,那是不是可以一下解决问题?

在网上查找后发现确实可以设置SSL验证全局取消(参考Py 坑之 CERTIFICATE_VERIFY_FAILED)。

因此,在/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py中顶部直接插入两行代码取消SSL验证

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

两种方法最终结果都是升级成功: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
Hit 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
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Add distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
updated cache in /home/eco/.ros/rosdep/sources.cache

成功升级,至此终于完成rosdep初始化,问题解决,大功告成。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值