關於安裝ROS時出現的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.
解決辦法
第一步
網上很多都說在/etc/hosts文件里加各種IP什么的,但是好像因為翻不了牆所以無法使用,最后試了好多種方法發現其中一個博主的方法是很可靠的。
先去百度連接下載文件,https://pan.baidu.com/s/1hKFJp_PQaela6i7RMOh5ZA,提取碼:bryv
下載后將文件放入ubuntu的一個文件夾下。
第二步
修改這個包中rosdep/source.list.d/下的文件20-default.list,將這個文件中指向raw.githubusercontent.com的url地址全部修改為指向本地文件的地址,也就是該下載好的包的地址,可以進入rosdistro-master的文件夾中的rosdep中的sources.list.d中,在終端輸入pwd查看路徑,將路徑復制,再修改20-default.list中的內容。
# os-specific listings first yaml file:///home/xxx/rosdep/osx-homebrew.yaml osx
# generic yaml file:///home/xxx/rosdep/base.yaml
yaml file:///home/xxx/rosdep/python.yaml
yaml file:///home/xxx/rosdep/ruby.yaml
gbpdistro file:///home/xxx/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
注意是file://+路徑;
第三步
進入/usr/lib/python2.7/dist-packages/rosdep2該文件夾下面的sources_list.py文件里面。而這個文件里面的代碼則進行了訪問raw.githubusercontent.com的操作,因此修改該默認url即可。以下是樣例:
# default file to download with 'init' command in order to bootstrap # rosdep DEFAULT_SOURCES_LIST_URL = 'file:///home/xxx/rosdep/sources.list.d/20-default.list' # seconds to wait before aborting download of rosdep data
第四步
修改以下兩個文件里面的代碼:
/usr/lib/python2.7/dist-packages/rosdep2/rep3.py /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
分別是
# location of targets file for processing gbpdistro files REP3_TARGETS_URL = 'file:///home/xxx/releases/targets.yaml' # seconds to wait before aborting download of gbpdistro data
# index information DEFAULT_INDEX_URL = 'file:///home/xxx/index-v4.yaml' def get_index_url():
這個文件是在rosdistro-master中,不需要進入子目錄。
最后
然后進行sudo rosdep init :
激動人心的時刻來了:
成功!
原文鏈接:https://blog.csdn.net/qq_43046763/article/details/116225256