Rosanswers logo


I create a test package as tutorial using

catkin_create_pkg beginner_tutorials std_msgs rospy roscpp.

When I add a custom message, it comes error

[100%] Built target beginner_tutorials_generate_messages_lisp

Traceback (most recent call last):

File "/opt/ros/kinetic/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 41, in

import genmsg.template_tools

File "/opt/ros/kinetic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 39, in

import em

ImportError: No module named 'em'

beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_cpp.dir/build.make:62: recipe for target '/home/arnoldx201/catkin_ws/devel/include/beginner_tutorials/Complex.h' failed

make[2]: *** [/home/arnoldx201/catkin_ws/devel/include/beginner_tutorials/Complex.h] Error 1 CMakeFiles/Makefile2:1136: recipe for target 'beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_cpp.dir/all' failed

make[1]: *** [beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_cpp.dir/all] Error 2

Makefile:138: recipe for target 'all' failed

make: *** [all] Error 2

Invoking "make -j4 -l4" failed

When I use directly python --> import cm, there is no problem.

Has anyone met the same problem before? Thanks

Originally posted by tomcattiger on ROS Answers with karma: 1 on 2017-03-23

Post score: 0

Original comments

Comment by fettespferd on 2019-01-21:
Hattest du eine Lösung für dein Problem gefunden?

Ich stehe momentan vor dem exakt gleichen Problem und komme nicht weiter :(


3 Answers 3


Rosanswers logo

Yes, other users have seen this before.

A quick search on this site for the title of your question turns us: http://answers.ros.org/question/257331/python-module-empy-missing-tutorials/ , http://answers.ros.org/question/239285/invoking-make-j4-l4-failed-importerror-no-module-named-em/ and http://answers.ros.org/question/228285/invoking-make-j4-l4-failed-linux-mint/ , all of which describe different causes for this error and possible solutions.

Originally posted by ahendrix with karma: 47576 on 2017-03-24

This answer was ACCEPTED on the original site

Post score: 4

Original comments

Comment by mkelly66 on 2019-07-22:
I had this same problem. The first link had the solution that solved it for me. I needed to install the python empy library. "pip install empy" and then "catkin_make" worked. Thanks!


Rosanswers logo

I have fixed this by running sudo apt-get install python3-empy

Originally posted by bobo_truth with karma: 71 on 2019-12-11

This answer was NOT ACCEPTED on the original site

Post score: 6

Original comments

Comment by Lidor Shimoni on 2020-01-27:
worked for me too :)

Comment by Deepak_Kr_Yadav on 2020-02-21:
Worked for me too. THanks BUddy

Comment by Morna_Bot on 2020-05-18:
Thank You. After many tried, the 'sudo apt-get install python3-empy' works.

Comment by jlpm on 2020-06-11:
Thank you! This solved the problem.


Rosanswers logo

I had the same issue, which also came in the frieghtening forms of:

"ModuleNotFoundError: No module named 'ament_package'"


"ModuleNotFoundError: No module named 'catkin_pkg'"

And I've already had all of the above packages installed - so unfortunately none of the above solutions helped.

What does solve it for me, though, if anyone else is having the same issue, is the following:

Apparently the cause for these errors is a conflict I have with the PATH variable that anaconda sets. Because I use my conda environment more than I use ROS (for now...), I didn't want to comment out the setting in ~/.bashrc as suggested here.

So instead, before running colcon build (and after deleting the ill-made folders, if they are there already, build, install and log under the ws root folder), I use the following curse:

export PATH="/opt/ros/foxy/bin:"$(echo $PATH | sed 's/^[^:]*://g' | sed 's/^[^:]*://g' | sed 's/^[^:]*://g' | sed 's/^[^:]*://g')

Which deletes any mentioning of anaconda in the current terminal's PATH variable, and allows the building to occur (I'm pretty sure there are more elegant ways to do it, so please free to add)

Using that curse - start with echo $PATH to see what it looks like, and then add these | sed 's/^[^:]*://g' commands that delete all the characters in the string from its beginning until they reach a ":". Just use echo $PATH | sed 's/^[^:]*://g' to see what you get. I added /opt/ros/foxy/bin: in the beggining of PATH but I'm not really sure about it. It worked for me, anyway.

For easier usage you can also create a .bash file that contains that line. I copied the line into ~/ROS2/update_path.bash and now before building I call . ~/ROS2/update_path.bash and it's working (use echo $PATH again just to see there is indeed no anaconda in the current PATH)

Hope it helps!

Originally posted by DoriNissenbaum with karma: 21 on 2021-01-27

This answer was NOT ACCEPTED on the original site

Post score: 2


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.