catkin_make: ImportError: No module named 'error'

asked 2020-01-12 04:17:06 -0600

updated 2020-01-12 05:27:14 -0600

gvdhoorn gravatar image

I try to learn ROS Tutorials in topic "Creating a ROS msg and srv" but in finally I can't $ catkin_make install

this is result :

snow@snow-PE60-2QE:~/catkin_ws$ catkin_make install
Base path: /home/snow/catkin_ws
Source space: /home/snow/catkin_ws/src
Build space: /home/snow/catkin_ws/build
Devel space: /home/snow/catkin_ws/devel
Install space: /home/snow/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/snow/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/snow/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/snow/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/snow/catkin_ws/devel;/opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.5.2", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/snow/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found PythonInterp: /usr/bin/python3 (found version "3.5.2") 
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.20
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - beginner_tutorials
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'beginner_tutorials'
-- ==> add_subdirectory(beginner_tutorials)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- beginner_tutorials: 1 messages, 0 services
-- Configuring done
-- Generating done
-- Build files have been written to: /home/snow/catkin_ws/build
####
#### Running command: "make install -j8 -l8" in "/home/snow/catkin_ws/build"
####
Scanning dependencies of target _beginner_tutorials_generate_messages_check_deps_Num
Scanning dependencies of target std_msgs_generate_messages_eus
Scanning dependencies of target std_msgs_generate_messages_lisp
Scanning dependencies of target std_msgs_generate_messages_py
Scanning dependencies of target std_msgs_generate_messages_nodejs
Scanning dependencies of target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target _beginner_tutorials_generate_messages_check_deps_Num
Scanning dependencies of target beginner_tutorials_generate_messages_py
Scanning dependencies of target beginner_tutorials_generate_messages_lisp
Scanning dependencies of target beginner_tutorials_generate_messages_cpp
Scanning dependencies of target beginner_tutorials_generate_messages_nodejs
Scanning dependencies of target beginner_tutorials_generate_messages_eus
[ 28%] Generating C++ code from beginner_tutorials/Num.msg
[ 28%] Generating Python from MSG beginner_tutorials/Num
[ 42%] Generating EusLisp manifest code for beginner_tutorials
[ 57%] Generating Lisp code from beginner_tutorials/Num.msg
[ 71%] Generating Javascript code from beginner_tutorials/Num.msg
[ 85%] Generating EusLisp code from beginner_tutorials/Num.msg
[ 85%] Built target beginner_tutorials_generate_messages_lisp
[ 85%] Built target beginner_tutorials_generate_messages_nodejs
Traceback (most recent call last):
  File "/opt/ros/kinetic/share/genpy/cmake/../../../lib/genpy/genmsg_py.py", line 44, in <module>
    import genpy.generator
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/message.py", line 44, in <module>
    import yaml
  File "/usr/lib/python2.7/dist-packages/yaml/__init__.py", line 2, in <module>
    from error import *
ImportError: No module named 'error'
beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_py.dir/build.make:62: recipe for target '/home/snow/catkin_ws/devel/lib/python3/dist-packages/beginner_tutorials/msg/_Num.py' failed
make[2]: *** [/home/snow/catkin_ws/devel/lib/python3/dist-packages/beginner_tutorials/msg/_Num.py] Error 1
CMakeFiles/Makefile2:567: recipe for target 'beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_py ...
(more)
edit retag flag offensive close merge delete

Comments

I've changed the title of your question, as ImportError: No module named 'error' is the real issue here.

gvdhoorn gravatar imagegvdhoorn ( 2020-01-12 05:27:34 -0600 )edit
1

As to your question: please try searching with Google for the error message you get. Something like: "ImportError: No module named 'error'" site:answers.ros.org as a search query should return quite some results.

Summarising: you're mixing Python 2 and Python 3. That will not work, as modules installed for Python 2 will not be available to Python 3 and vice-versa.

gvdhoorn gravatar imagegvdhoorn ( 2020-01-12 05:28:48 -0600 )edit

Thank you! after I remove Python 3 it can be worked!

Neonidust gravatar imageNeonidust ( 2020-01-13 02:32:54 -0600 )edit