ubuntu16 安裝ROS Kinetic:sudo rosdep init 和 rosdep update 報錯
前段時間手賤重裝了ubuntu16.04,在安裝ROS的時候,sudo rosdep init 和 rosdep update 報錯了,折騰了半天最終處理好了,把出坑經歷記錄下來:
一、sudo rosdep init 報錯
報錯信息如下:
$ 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 報錯
可能會出現下面的兩種錯誤
報錯內容一:
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)>
解決方法:
參考: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]:
<urlopen error ('_ssl.c:574: The handshake operation timed out',)> (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.c:574: The handshake operation timed out',)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
ERROR: error loading sources list:
('The read operation timed out',)
顯示是時間超時,原因是網絡的問題,需要現在使用的是WIFI的話,可以換成熱點試一試。再運行的時候可能會失敗,但是多多試幾次,肯定會成功的!