参考:https://zhuanlan.zhihu.com/p/392082731
sudo rosdep init
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 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
rosdep update
1.打开包含资源下载函数的文件:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
- 在311行处添加代理:
url="https://ghproxy.com/"+url
下面是代码修改的位置
def download_rosdep_data(url):
"""
:raises: :exc:`DownloadFailure` If data cannot be
retrieved (e.g. 404, bad YAML format, server down).
"""
try:
# http/https URLs need custom requests to specify the user-agent, since some repositories reject
# requests from the default user-agent.
url="https://ghproxy.com/"+url
- 修改/usr/lib/python2.7/dist-packages/rosdistro/init.py文件中的DEFAULT_INDEX_URL
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
ctrl f 搜索一下DEFAULT_INDEX_URL,将这一行改为
EFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
- 修改其余(4个)文件中的地址,在地址 https://raw.githubusercontent.com/… 前添加https://ghproxy.com/
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
//修改第36行的地址
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py 72行
//修改第72行
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
//修改第39行
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/manifest_provider/github.py
//修改第68行、119行
- 解决 Hit 第五个地址的报错
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
//在第204行添加如下代码(即在该函数块下的第一行处)
gbpdistro_url = "https://ghproxy.com/" + gbpdistro_url
//注意,原网址中代理地址的双引号是中文,直接粘贴复制会报字符识别错误
我加在了这里
def download_gbpdistro_as_rosdep_data(gbpdistro_url, targets_url=None):
"""
Download gbpdistro file from web and convert format to rosdep distro data.
DEPRECATED: see REP137. This function will output
(at least) one deprecation warning
:param gbpdistro_url: url of gbpdistro file, ``str``
:param target_url: override URL of platform targets file
:raises: :exc:`DownloadFailure`
:raises: :exc:`InvalidData` If targets file does not pass cursory
validation checks.
"""
# we can convert a gbpdistro file into rosdep data by following a
# couple rules
# will output a warning
gbpdistro_url = "https://ghproxy.com/" + gbpdistro_url
- 再次运行 rosdep update ,发现问题完美解决!