Python own Message Load Problem - ImportError: unknown location - Windows 10

asked 2021-12-10 04:38:43 -0500

Hi together,

I have a trouble with ROS - noetic on WIndos 10. In the text following i try to explain my problem. Thanks for your help.

Side Informations:

The first problem was, if I start my beginner_tutorials there came an Error:

rosrun beginner_tutorials scripts/


The command ""\python.exe"" is either misspelled or could not be found.

I solved it with: Add User Variable: PYTHONHOME - C:\opt\ros\noetic\x64

Then came the next Error if I run:

rosrun beginner_tutorials scripts/


[rosrun] Couldn't find executable named scripts/

I solved it with: Add User Variable: PYTHONPATH - C:\opt\ros\noetic\x64\share

Now I can start the beginner_tutorials script from the ROS Tutorial - Writing Publisher and Subscriber with Python with:

rosrun beginner_tutorials scripts/

The next step for me was to test an own msg-File:

I added a new message file Num.msg

I'am adding with the Tutorial the parameters needed in package.xml and CMakeLists.txt. I made some changes in the for using my own msg-File. I run the setup.bat in devel-folder and run catkin_make.

Then I try to start:

rosrun beginner_tutorials scripts/

The Error:

Traceback (most recent call last):Traceback (most recent call last):
   File "c:\opt\ros\noetic\x64\share\beginner_tutorials\scripts\", line 41, in <module>
    from beginner_tutorials.msg import Num
ImportError: cannot import name 'Num' from 'beginner_tutorials.msg' (unknown location)

I have checked the files several times and tested the package on a Ubuntu System. There it works. I tested before run "rosrun" do "roscd".

Did anybody have an idea?

Thanks a lot.

files of the Package:

  • beginner_tutorials
    • msg
      • Num.msg
    • scripts
    • CMakeLists.txt
    • package.xml

my Num.msg:

int64 Num

my script:

#!/usr/bin/env python
import rospy
from std_msgs.msg import String
from beginner_tutorials.msg import Num

def talker():
    pub = rospy.Publisher('chatter', Num, queue_size=10)
    rospy.init_node('talker', anonymous=True)
    rate = rospy.Rate(10) # 10hz
    while not rospy.is_shutdown():
        hello_str = 5

if __name__ == '__main__':
    except rospy.ROSInterruptException:

my package.xml (without Standard comments):

<?xml version="1.0"?>
<package format="2">

  <maintainer email="">Name</maintainer>

  <build_depend>roscpp</build_depend> ...
edit retag flag offensive close merge delete


Try: from beginner_tutorials.msg import num instead

osilva gravatar image osilva  ( 2021-12-10 10:43:21 -0500 )edit

The message String from standard messages is capitalized but num.msg message in the begginner_tutorialsis not.

osilva gravatar image osilva  ( 2021-12-10 10:44:35 -0500 )edit