赞
踩
记录一下,今天给一台x86机子装了ros系统,sudo ros init时候,报了错误:
- File "/usr/bin/rosdep", line 6, in <module>
- from pkg_resources import load_entry_point
- File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
- @_call_aside
- File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
- f(*args, **kwargs)
- File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
- working_set = WorkingSet._build_master()
- File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 635, in _build_master
- ws.require(__requires__)
- File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 943, in require
- needed = self.resolve(parse_requirements(requirements))
- File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 829, in resolve
- raise DistributionNotFound(req, requirers)
- pkg_resources.DistributionNotFound: The 'rosdep==0.21.0' distribution was not found and is required by the application
一:问题
我们知道,ros 默认的python库应该是python,而看起来报的错误全是python3,那么而已得知python库需要切换下。
python --version 先看一下目前额python版本,
- python --version
- Python 3.5.2
二:解决
1:查看python2的位置:
- which python2
- /usr/bin/python2
2:切换python默认版本
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 150
3:查看可选择的版本:
- update-alternatives --list python
- /usr/bin/python2
4:切换:sudo update-alternatives --config python
如果只看一个,那无所谓了,也不用config了,我的就是如此了
- sudo update-alternatives --config python
- 链接组 python (提供 /usr/bin/python)中只有一个候选项:/usr/bin/python2
- 无需配置。
5:查询版本,最好重新打开一个终端
- python --version
- Python 2.7.12
搞定!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。