ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
4

python module empy missing - Tutorials

asked 2017-03-18 17:22:26 -0600

philglau gravatar image

updated 2017-03-18 17:28:34 -0600

I'm walking through the tutorials and am on Introduction to msg and srv

I'm using Ubuntu 16.04 and Kinetic. My python is /usr/bin/python My pip is /usr/local/bin/pip

I'm running the command catkin_make install on Step 6 and I get the following 'em' not found error:

[ 69%] Generating Javascript code from beginner_tutorials/Num.msg
[ 76%] Generating C++ code from beginner_tutorials/Num.msg
[ 84%] Generating Javascript code from beginner_tutorials/AddTwoInts.srv
Traceback (most recent call last):
  File "/opt/ros/kinetic/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 41, in <module>
    import genmsg.template_tools
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 39, in <module>
    import em
ImportError: No module named em
beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_cpp.dir/build.make:63: recipe for target '/home/philglau/catkin_ws/devel/include/beginner_tutorials/Num.h' failed
make[2]: *** [/home/philglau/catkin_ws/devel/include/beginner_tutorials/Num.h] Error 1
make[2]: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "/opt/ros/kinetic/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 41, in <module>
    import genmsg.template_tools
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 39, in <module>
    import em
ImportError: No module named em
beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_cpp.dir/build.make:70: recipe for target '/home/philglau/catkin_ws/devel/include/beginner_tutorials/AddTwoInts.h' failed

So obviously, it thinks em is missing. So I ran both of the following to try to resolve it:

philglau@phil-glau-ubuntu-16:~$ sudo -H pip install empy
Requirement already satisfied: empy in /usr/lib/python2.7/dist-packages

And also tried:

philglau@phil-glau-ubuntu-16:~$ sudo apt-get install python-empy
[sudo] password for philglau: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-empy is already the newest version (3.3.2-1build1).
python-empy set to manually installed.
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-59 linux-headers-4.4.0-59-generic linux-image-4.4.0-59-generic linux-image-extra-4.4.0-59-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

And if I manually load python from the CLI, I can import em without it barking

philglau@phil-glau-ubuntu-16:~/catkin_ws$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import em
>>>

Likewise if I directly run template_tools.py from the CLI it doesn't bark either:

python /opt/ros/kinetic/lib/python2.7/dist-packages/genmsg/template_tools.py

I also 'reinstalled' ROS and it said 'nothing was updated.' I have not yet attempted to completely uninstall and then re-install, but hopefully that won't be necessary.

After all my attempts to fix this problem, I'm still getting the package not found error when running catkin_make as indicated in the tutorial. Any thoughts??

Thank you in advance for any help. - Phil

edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted
18

answered 2017-03-19 17:49:17 -0600

philglau gravatar image

I think this has to do with a conflict between the python module 'em' and 'empy' both of which use the same name.

If you have 'em' installed, it seems to supersede 'empy' which is what is needed by ROS.

See this link for details

I ended up compiling from source before I figured this out. To resolve it on my self-compiled kinetic, I did:

pip uninstall em
pip install empy

And it seems to have fixed the problem. Kind of a frustrating error as the apt-get install covered in the tutorial doesn't automatically detect this conflict.

edit flag offensive delete link more

Comments

It works. thanks

Cabbage gravatar image Cabbage  ( 2017-10-07 00:56:59 -0600 )edit

This fixed my problem, thank you!

katastrophe gravatar image katastrophe  ( 2020-06-30 17:11:20 -0600 )edit
2

answered 2017-09-02 10:01:46 -0600

theLXK gravatar image

updated 2017-09-02 10:02:00 -0600

Apparently re-installing or adding empy is not enough.

If you used another interpreter (e.g. Anaconda, virtualenv) etc. they may leave links to cache inside your catkin workspace if you accidentally used them before. This messes up the $PYTHONPATH which was prepending python3 libs from anaconda in my case, even though I wasn't sourcing anaconda anywhere afterwards.

What made it work was the following:

  1. source ros from /opt/ros/kinetic/setup.zsh
  2. clean up your catkin workspace (except src)

    cd ~/catkin_ws
    unlink src/CMakeLists.txt
    rm -rf build
    rm -rf devel
    rm .catkin_workspace
    
  3. re-initialize the workspace with catkin_init_workspace from inside src

  4. catkin_make
edit flag offensive delete link more

Comments

I am using a conda env and it worked for me. Only re-installing empy didn't work, I needed to init the workspace again as mentioned.

davidQ gravatar image davidQ  ( 2019-03-19 09:15:02 -0600 )edit

This worked for me after having issues with the "em" package. This was likely because I had first run catkin_make from an anaconda environment.

globidio gravatar image globidio  ( 2023-02-28 03:36:44 -0600 )edit
1

answered 2017-03-23 02:57:44 -0600

130s gravatar image

updated 2017-03-23 03:01:34 -0600

ROS has been IMO absolutely doing great job in making installation of this large amount of packages as easy as possible. Usually when you're on an officially supported OS like Ubuntu (full list for Kinetic), there's no need for hacking installation steps at all. In case you had to, then it's most likely something was done in a wrong way during installation.

I have not yet attempted to completely uninstall and then re-install, but hopefully that won't be necessary.

I would definitely clean and re-install all ros by something like following (running these two commands will only take a few seconds aren't they? (running time is long though):

apt-get purge ros-kinetic*
apt-get install ros-kinetic-X  (whatever you need)

Just FYI, python-empy is depended by some core ROS packages on my Kinetic, meaning you don't even need to bother installing it explicitly:

$ apt-cache rdepends python-empy
  python-empy
  Reverse Depends:
  python3-empy
  ros-lunar-catkin
  ros-kinetic-catkin
  python-ros-buildfarm-modules
  python-ros-buildfarm
  python-bloom
  catkin
  python-empy-doc
  python-bloom
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial

Only possible situation where you may have to manually do something specific to the issue raised in this thread is when you already have em installed on your computer. In that case uninstall it in advance if possible.

edit flag offensive delete link more
1

answered 2019-12-11 00:25:00 -0600

bobo_truth gravatar image

I fixed it just by running:
sudo apt-get install python3-empy

edit flag offensive delete link more

Comments

this is the url of python3-empy https://packages.debian.org/testing/p...

bobo_truth gravatar image bobo_truth  ( 2019-12-11 00:25:56 -0600 )edit
-2

answered 2021-03-09 23:54:49 -0600

navalctm gravatar image

If you are facing this issue w.r.t. python3 then

https://medium.com/@beta_b0t/how-to-s...

edit flag offensive delete link more

Comments

1

Can you please update your answer with the main points from the article that you linked to? Link-only answers are discouraged and medium articles are often behind a paywall making this answer less valuable

jayess gravatar image jayess  ( 2021-03-11 00:05:55 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2017-03-18 17:22:26 -0600

Seen: 36,910 times

Last updated: Mar 09 '21