pkg_resources.DistributionNotFound: The 'rosdep==0.19.0' distribution was not found and is required by the application
在我安装完ros-kinetic版本之后,需要进行初始化
sudo rosdep init
这个时候系统报了一个错误信息提示我某样东西没有安装
pkg_resources.DistributionNotFound: The 'rosdep==0.19.0' distribution was not found and is required by the application
上网搜索资料之后说是需要安装Python3.5 版本的 rosdep(错误示范开始了!!!!!!)
sudo apt install python3-rosdep
为了安装这个,又需要去安装一堆依赖库
sudo apt-get install python3-catkin-pkg
sudo apt-get install python3-rospkg
sudo apt-get install python3-rosdep-modules
神奇的是,你会发现在安装这些的时候ros当中的很多组建被奇怪的卸载掉了!!
不信的话你再运行一遍
sudo apt-get install ros-kinetic-desktop-full
会发现还有很多东西没安装,如果又重新安装了,又会报最先前的错误,于是又去重新装 Python3.5 版本的 rosdep,反反复复死循环。。。。。。。
问题出现的真实原因其实是Ros-kinetic使用的是python2版本的rosdep,而电脑系统python版本是python3造成的。我们将系统python版本换到python2就可以了。
查看当前系统Python版本
python --version
查看发现默认的版本的确被修改为python3.5了,但其实Ubuntu系统本身就自带有python2的版本
update-alternatives --list python
通过指令查看一下系统都要哪些版本的Python 通常都会有Python2.7的
/usr/bin/python2.7
/usr/bin/python3.5
如果在list python那一步报错,则表示 Python 的替代版本尚未被update-alternatives 命令识别,具体解决方案请自行Google/Baidu,比较简单我就不再赘述了。
sudo update-alternatives --config python
如果上面命令都没有出问题的话,会出现以下信息
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3 150 auto mode
* 1 /usr/bin/python2 100 manual mode
2 /usr/bin/python3 150 manual mode
Press to keep the current choice[*], or type selection number:
我们需要将Python版本切换为Python2,因此输入数字1,然后Enter就大功告成了。
后面的步骤在网上各大教程里都有详细说明,我就不再说明了。
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
roscore
有可能会碰到一个问题,在进行初始化的时候提示
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
这表示你之前其实是初始化过ROS了,不管是通过错误还是正确的方法,都初始化过了,因此本应该创建的文件已经存在,这时只要删掉该文件再重新进行初始化就好了。
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list