Ask Your Question
0

ImportError: No module named rosmaster.master_api

asked 2019-02-19 16:49:37 -0600

nsy gravatar image

updated 2019-02-22 14:57:16 -0600

gvdhoorn gravatar image

Hi,

When I run command "roscore", I face with the following error:

Traceback (most recent call last):
  File "/opt/ros/melodic/bin/roscore", line 36, in <module>
    from rosmaster.master_api import NUM_WORKERS
ImportError: No module named rosmaster.master_api

I am working with melodic Ros on ubuntu 18.04. would you please help me? what is the problem?


Edit: My default python is 2.7. I couldn't run this

from rosmaster.master_api import NUM_WORKERS

in Python 3 too.

I installed ROS by apt-get install ros-desktop-melodic-full.


Edit 2: The answers are as follow:

$ which python
/usr/bin/python
$ python --version
Python 2.7.15rc1
$ ls -al /opt/ros/melodic/lib/python2.7/dist-packages/rosmaster
ls: cannot access '/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster': No such file or directory

Thanks so much

edit retag flag offensive close merge delete

Comments

1

what is the problem?

do you have Python 3 / Anaconda installed and configured that as the default Python interpreter?

How did you install ROS?

gvdhoorn gravatar image gvdhoorn  ( 2019-02-20 02:38:00 -0600 )edit

What is the output of which python, python --version and ls -al /opt/ros/melodic/lib/python2.7/dist-packages/rosmaster?

gvdhoorn gravatar image gvdhoorn  ( 2019-02-21 02:12:15 -0600 )edit

It would appear you don't have the rosmaster Python pkg.

Could you try the following?

sudo apt update
sudo apt install -y ros-melodic-rosmaster

and tell us the output?

gvdhoorn gravatar image gvdhoorn  ( 2019-02-22 14:58:24 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2020-07-25 11:54:28 -0600

ChrisL8 gravatar image

I just had this exact same error and the issue was that I needed to run:

source /opt/ros/noetic/setup.bash

(or .zsh as your case may be)

This should be put into your .bashrc (or .zshrc), but if you forgot or didn't, it will cause the above error.

edit flag offensive delete link more
0

answered 2019-02-22 15:48:41 -0600

nsy gravatar image

updated 2019-02-22 18:55:46 -0600

jayess gravatar image

I think I had two different versions of Ros. I removed all installed Ros in my system by the following command and installed it again by

apt-get install ros-melodic-desktop-full

and my problem solved.

sudo apt-get remove `apt list --installed |grep ros- |cut -d '/' -f 1 |xargs`
edit flag offensive delete link more

Comments

Which two versions? Melodic only installs on Ubuntu Bionic, and Kinetic only on Xenial. There is no overlap possible.

Unless you've build ROS from source, but that should not interfere with the Python modules (they would be the same).

gvdhoorn gravatar image gvdhoorn  ( 2019-02-23 01:40:53 -0600 )edit

at the first time, I installed Ros by running "apt-get instal ros-melodic-desktop-full ". But because of some errors in running catkin, I install catkin and some other packages from source. Indeed, I don't know what was my problem but by removing all Ros Ropackages and installing it again, it solved

nsy gravatar image nsy  ( 2019-02-23 15:04:41 -0600 )edit
0

answered 2021-01-29 23:14:54 -0600

updated 2021-02-08 15:47:20 -0600

I'm using ROS noetic in 5.9.14-arch1-1 (ArchLinux) And i solved problem by create catkin workspace. I think you haven't create your own workspace just follow this link http://wiki.ros.org/catkin/Tutorials/.... And try run roscore again. Thank you :D

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-02-19 16:49:37 -0600

Seen: 3,628 times

Last updated: Feb 08