ImportError : No module named xxx.msg. CMakeLists.txt, package.xml, terminal output, code
Hi,
I am very tired trying more and more, but I want to try unless i accomplish.
I have already read dozens of ros.org links and watched two popular youtube videos according to this ImportError problem:
https://www.youtube.com/watch?v=NKeebwRNvv8&feature=youtu.be
https://www.youtube.com/watch?v=ZPmlFNb7v4Y
I am doing exactly as they say, however at the end I still get this f**king error ImportError!!
Please, help me who is aware of this problem.
I have changed Cmakelists, package.xml, everything everything, but still((( Everything is going exactly the same as these videos, but at the last minutes of video I am getting ImportError
Asked by Nurbek on 2019-05-07 10:41:37 UTC
Comments
Can you post some information about your problem? To help you we'd need to see the exact error and your CMakeLists.txt and package.xml
Asked by Carl D on 2019-05-07 13:22:01 UTC
Thanks.
My package.xml (besides comments):
My CMakeLists.txt(the places where I made changes):
find_package(catkin REQUIRED COMPONENTS std.msgs message_generation )
add_message_files( FILES Robotjon.msg )
generate_messages( DEPENDENCIES std_msgs
)
catkin_package(
CATKIN_DEPENDS message_runtime
)
My python code:
! /usr/bin/env python
import rospy
from mode_publishers.msg import Robotjon
rospy.init_node('topic_publisher') pub = rospy.Publisher('/topic_ex', Robotjon, queue_size=1) rate=rospy.Rate(2) message = Robotjon() message.custom_msg = "Hello World"
while not rospy.is_shutdown(): pub.publish(message) rate.sleep()
My Robotjon.msg:
string custom_msg
My Robotjon.msg file is inside the mode_publishers package
Asked by Nurbek on 2019-05-07 13:43:28 UTC
I don't see anything obviously wrong with the snippets you've posted. Here's some things to check: 1. Is
Robotjon.msg
in themode_publishers/msg
directory. 2. Are there any spelling mistakes? Maybe an extra _ or ani
instead of aj
? 3. Do you get any errors when you run catkin_make? 4. Does the package name in thepackage.xml
file match the package name in theCMakeLists.txt
? 5. After you source devel/setup.bash what do you have in your PYTHONPATH environment variable? Does mode_publishers show up?Asked by Carl D on 2019-05-07 14:55:39 UTC
Robotjon
is in themode_publishers/msg
directory.Asked by Nurbek on 2019-05-07 16:33:16 UTC
When I am running rosmsg show Robotjon:
I think everything is ok
Asked by Nurbek on 2019-05-07 16:50:01 UTC
BUT During running catkin_make I noticed that there are no such messages in my terminal during compiling like in youtube videos:
[16%] BUILT TARGET <name of package>_generate_messages
Scanning dependencies.....[33%] BUILT TARGET <name of package>_generate_messages
Scanning dependencies.....[50%] BUILT TARGET <name of package>_generate_messages
Scanning dependencies.....[66%] BUILT TARGET <name of package>_generate_messages
Scanning dependencies.....[83%] BUILT TARGET <name of package>_generate_messages
Scanning dependencies.....[100%] BUILT TARGET <name of package>_generate_messages
Scanning dependencies.....Asked by Nurbek on 2019-05-07 16:59:40 UTC
@Nurbek can you please update your question with this information (code, package.xml, CMakelists.txt, terminal output)? Having this information in the comments in the comments makes your question difficult to follow.
Asked by jayess on 2019-05-07 18:52:38 UTC
Also, did you
source
yoursetup.bash
file? I.e., runfrom the root of your workspace?
Asked by jayess on 2019-05-07 19:55:12 UTC
Yes, I did
Asked by Nurbek on 2019-05-08 01:22:32 UTC
Two other simple things that could go wrong:
source devel/setup.bash
If that isn't it, it seems likely that something is going wrong with your build, so it might help to see the build output.
What should happen when you run catkin_make is that a Robotjon.py file is generated in a sub-directory of the
devel
directory in your workspace (sorry I don't remember the exact path off hand. It'll be something likedevel/share/lib/mode_publishers/msg/Robotjon.py). When you source
devel/setup.bash` that path to your package should be added to the PYTHON_PATH environment variable.So if the file is not there, please post your complete CMakeLists.txt and your build output because that's where the problem probably lies.
Asked by Carl D on 2019-05-08 02:09:16 UTC
Updating your question with the information in these comments (e.g., the code, package.xml, etc) so that it's formatted and easy to read and follow will also go a long way to getting your question answered.
Asked by jayess on 2019-05-08 02:34:24 UTC
Thank you! I created a new workspace and tried everything from the beginning. Now it works.
The problem is that I used "old" created workspace and there could be some errors
Asked by Nurbek on 2019-05-08 05:49:37 UTC