Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ArghyaChatterjee/f521aaa1879765902436531d697aa680 to your computer and use it in GitHub Desktop.
Save ArghyaChatterjee/f521aaa1879765902436531d697aa680 to your computer and use it in GitHub Desktop.

Building ROS Melodic with python3 support

Quick gist to accompany post on building ROS Melodic w/python3 support

remove all things python (optional)

sudo apt-get remove python-*

remove previous installations of ROS

sudo apt-get remove ros-* sudo apt-get remove ros-melodic-* sudo apt-get autoremove

setup python3 dependencies

sudo apt update sudo apt install -y python3 python3-dev python3-pip build-essential sudo -H pip3 install rosdep rospkg rosinstall_generator rosinstall wstool vcstools catkin_tools catkin_pkg

initializ catkin build environment

sudo rosdep init rosdep update cd ~ mkdir ros_catkin_ws cd ros_catkin_ws

TODO: get rqt_rviz rviz_plugin_tutorials librviz_tutorial building w/python3

catkin config --init -DCMAKE_BUILD_TYPE=Release --blacklist rqt_rviz rviz_plugin_tutorials librviz_tutorial --install

setup ROS install

rosinstall_generator desktop_full --rosdistro melodic --deps --tar > melodic-desktop-full.rosinstall wstool init -j8 src melodic-desktop-full.rosinstall

if packages fail to download, run the following

wstool update -j4 -t src

setup environment and install dependencies

export ROS_PYTHON_VERSION=3 pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython

create the following script in the ros_catkin_ws directory and call it install_skip

#!/bin/bash #Check whether root if [ $(whoami) != root ]; then echo You must be root or use sudo to install packages. return fi

#Call apt-get for each package for pkg in "$@" do echo "Installing $pkg" sudo apt-get -my install $pkg >> install.log done

and chmod it

chmod +x install_skip

sed magic

sudo ./install_skip rosdep check --from-paths src --ignore-src | grep python | sed -e "s/^apt\t//g" | sed -z "s/\n/ /g" | sed -e "s/python/python3/g" rosdep install --from-paths src --ignore-src -y --skip-keys="rosdep check --from-paths src --ignore-src | grep python | sed -e "s/^apt\t//g" | sed -z "s/\n/ /g"" find . -type f -exec sed -i 's//usr/bin/env[ ]*python//usr/bin/env python3/g' {} +

build ROS

catkin build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment