13

I have installed ROS indigo and gazebo2 packages in Ubuntu 14.04.5. When I try to use catkin command, I get:

catkin_init_workspace : command not found

So, I tried to install catkin, it displays that ros-indigo-catkin is the latest version.

All I did was,

$ sudo apt-get install ros-indigo-desktop-full

$ sudo apt-get install gazebo2.<They're installed perfectly>

After this, I am getting catkin issue.

Help needed. Someone please find a way to fix this issue.

lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228
Kathiravan Natarajan
  • 3,158
  • 6
  • 22
  • 45

4 Answers4

35

Had almost the same issue when i tried to run this command (please refer to the pics attached).

$ catkin build

Screenshot for solution applied to solve catkin build error
I solved it by installing catkin ROS build system using the command below (references attached in the links and pictures attached). Screenshot for catkin build error

$ sudo apt-get install ros-kinetic-catkin python-catkin-tools 
Pavel Smirnov
  • 4,611
  • 3
  • 18
  • 28
Arafat Mukasa
  • 451
  • 1
  • 4
  • 3
  • 2
    This solved it for me. I was missing python-catkin-tools specifically. – Robert Bain Mar 15 '20 at 03:09
  • 2
    This helped me as well. FYI, "sudo apt-get install ros-$ROS_DISTRO-catkin python-catkin-tools " will run against whatever ROS version you have. – VoteCoffee Aug 26 '20 at 22:07
  • 2
    For noetic and later that use Python 3 this answer is not correct. See @drewlufkin answer below what is correct (install Python 3 versions of these packages) – Audrius Meškauskas Dec 07 '21 at 08:49
22

If the workspace is setup, you properly sourced ROS as stated above, and if catkin_make works, but catkin build doesn't work do this:

sudo apt install python3-catkin-tools python3-osrf-pycommon

This is a catkin-tools dependency which was delinked in Ubuntu 20.04 so it has to be manually specified to be installed.

drewlufkin
  • 221
  • 2
  • 2
14

Probably you forgot to set up the environment after installing ROS.

$ echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
$ source ~/.bashrc

Then, I will assume you want to create a package, so you can follow these steps:

$ mkdir -p path_to_my_workspace/workspace_name/src
$ cd path_to_my_workspace/workspace_name/src
$ catkin_init_workspace
$ cd path_to_my_workspace/workspace_name/
$ catkin_make
$ source path_to_my_workspace/workspace_name/devel/setup.bash

After running these commands your workspace is created, so now you can start adding packages.

lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228
  • 1
    The first two lines will not work in a Dockerfile. See [Docker - Dockerfile: /bin/bash: catkin_init_workspace / catkin_make: command not found](https://robotics.stackexchange.com/a/21960/27423). The answer here is not wrong, since the question is not a Docker question. It just took me a while to find out that there is a difference, probably it is not the same in an image if you *source the .bashrc* and if you *source a setup.bash in one go*. – questionto42 Mar 29 '21 at 15:01
1

Maybe you didn't install "catkin ROS build system"

You can install it using the following command for ROS Melodic:

sudo apt-get install ros-melodic-catkin python-catkin-tool

or for ROS kinetic

sudo apt-get install ros-kinetic-catkin python-catkin-tool

If you want to create a ROS package, you can use: catkin create pkg myworkSpace --catkin-deps rospy this command will create a ROS workspace with a source folder, CMakeLists.txt and package.xml

or use

mkdir catkin
cd catkin
catkin create pkg myworkSpace --catkin-deps rospy

The provided commands are for Python. So, make sure to modify it for Cpp if you want so.

Mostafa Wael
  • 2,750
  • 1
  • 21
  • 23