Apollo 星火计划踩坑记录 dreamview启动报错“No such file or directory: ‘ping‘: ‘ping‘”

4 篇文章 0 订阅
2 篇文章 0 订阅

第一次以计算机科学与技术本科生身份写blog也是值得纪念的

百度Apollo开源社区近期开始了“星火计划第二期”,使用了新版本的工程框架,但是毕竟还在测试中,小bug不可避免,这篇blog记录一下很多开发者们遇到的这个问题。

以下是报错内容

jingqiao@in-dev-docker:/apollo_workspace$ bash scripts/apollo_neo.sh bootstrap start
Traceback (most recent call last):
  File "/usr/bin/buildtool", line 216, in <module>
    sys.exit(main() or 0)
  File "/usr/bin/buildtool", line 206, in main
    obj = PackageBuilder()
  File "/usr/bin/buildtool", line 75, in __init__
    self.entry_points = EntryPoints(entry_points_path, root_path, subparsers) 
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/entry_point.py", line 112, in __init__
    self.actions[verb] = all_lib_entry_points[verb].Action()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/build.py", line 51, in __init__
    super().__init__()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/__init__.py", line 63, in __init__
    self.decider = DeciderInterface()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/decider.py", line 139, in __init__
    self.metadata_cli = MetaDataCli()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/cyberfile/__init__.py", line 41, in __init__
    self.procedure = Procedure()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 46, in __init__
    self._ping_network()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 50, in _ping_network
    if subprocess.call(cmd) != 0:
  File "/usr/lib/python3.6/subprocess.py", line 287, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ping': 'ping'
[buildtool] INFO apollo build tool exit.
Traceback (most recent call last):
  File "/usr/bin/buildtool", line 216, in <module>
    sys.exit(main() or 0)
  File "/usr/bin/buildtool", line 206, in main
    obj = PackageBuilder()
  File "/usr/bin/buildtool", line 75, in __init__
    self.entry_points = EntryPoints(entry_points_path, root_path, subparsers) 
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/entry_point.py", line 112, in __init__
    self.actions[verb] = all_lib_entry_points[verb].Action()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/build.py", line 51, in __init__
    super().__init__()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/__init__.py", line 63, in __init__
    self.decider = DeciderInterface()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/decider.py", line 139, in __init__
    self.metadata_cli = MetaDataCli()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/cyberfile/__init__.py", line 41, in __init__
    self.procedure = Procedure()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 46, in __init__
    self._ping_network()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 50, in _ping_network
    if subprocess.call(cmd) != 0:
  File "/usr/lib/python3.6/subprocess.py", line 287, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ping': 'ping'
[buildtool] INFO apollo build tool exit.
[ERROR] Failed to start Dreamview. Please check dreamview.log or monitor.log for more information

分析报错信息可以发现问题出在ping上面。通过查看代码会发现核心问题在此文件中

/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py

以下就是导致报错的代码

    def _ping_network(self):
        cmd = ["ping", "-c", "1", "baidu.com"]
        if subprocess.call(cmd) != 0:
           self.online = False

有开发者使用将 if 直接注释掉解决了这个问题,博主亲测是可以的。简单分析下这个代码,这是一段检查网络的代码,ping baidu.com以测试网络。有开发者猜测可能是网络问题,但是国内baidu不可能连不上,看下报错内容提示是没有 ping。一般docker中使用的Ubuntu都是经过裁剪的,缺胳膊少腿是正常现象,所以我猜测可能是docker环境没有安装ping导致的,于是进行以下测试

jingqiao@in-dev-docker:/apollo_workspace$ ping www.baidu.com
bash: ping: command not found

果然是没有安装ping的问题,那问题就很好解决了

sudo apt install iputils-ping

再次测试

jingqiao@in-dev-docker:/apollo_workspace$ ping www.baidu.com
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=49 time=33.7 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=49 time=35.0 ms
jingqiao@in-dev-docker:/apollo_workspace$ bash scripts/apollo_neo.sh bootstrap
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=46 time=45.4 ms

--- baidu.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 45.453/45.453/45.453/0.000 ms
[buildtool] INFO Reconfigure apollo enviroment setup
[buildtool] INFO Done! Please activate the apollo enviroment setup by following command:
[buildtool] INFO 	source ~/.bashrc
[buildtool] INFO apollo build tool exit.
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=46 time=33.4 ms

--- baidu.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 33.496/33.496/33.496/0.000 ms
[buildtool] INFO Reconfigure apollo enviroment setup
[buildtool] INFO Done! Please activate the apollo enviroment setup by following command:
[buildtool] INFO 	source ~/.bashrc
[buildtool] INFO apollo build tool exit.
[INFO] Dreamview is running at http://localhost:8888

问题就解决了。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值