Rosanswers logo

Hi all,

I’m new in using linux and i’ve been trying to run ros 2 on linux 20.04. I’ve followed the “Installing ROS 2 on Linux” tutorial : https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Binary/

All have been fine until i run the command

ros2 run demo_nodes_py listener

and i get the following traceback :

Traceback (most recent call last):
File “/home/moutalib/ros2_foxy/ros2-linux/lib/demo_nodes_py/listener”, line 11, in
load_entry_point(‘demo-nodes-py==0.9.3’, ‘console_scripts’, ‘listener’)()
File “/home/moutalib/anaconda3/lib/python3.7/site-packages/pkg_resources/ init .py”, line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/home/moutalib/anaconda3/lib/python3.7/site-packages/pkg_resources/ init .py”, line 2854, in load_entry_point
return ep.load()
File “/home/moutalib/anaconda3/lib/python3.7/site-packages/pkg_resources/ init .py”, line 2445, in load
return self.resolve()
File “/home/moutalib/anaconda3/lib/python3.7/site-packages/pkg_resources/ init .py”, line 2451, in resolve
module = import (self.module_name, fromlist=[‘ name ’], level=0)
File “/home/moutalib/ros2_foxy/ros2-linux/lib/python3.8/site-packages/demo_nodes_py/topics/listener.py”, line 16, in
from rclpy.node import Node
File “/home/moutalib/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/node.py”, line 41, in
from rclpy.client import Client
File “/home/moutalib/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/client.py”, line 22, in
from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
File “/home/moutalib/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/impl/implementation_singleton.py”, line 31, in
rclpy_implementation = _import(’._rclpy’)
File “/home/moutalib/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/impl/ init .py”, line 27, in _import
return importlib.import_module(name, package=‘rclpy’)
File “/home/moutalib/anaconda3/lib/python3.7/importlib/ init .py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named ‘rclpy._rclpy’

I have tried to look on other topics but couldnt find a solution that works for me. I would be grateful if anyone can help me debug this problem. Thank you.

Originally posted by BadrMt on ROS Answers with karma: 23 on 2020-06-16

Post score: 2

Original comments

Comment by gvdhoorn on 2020-06-16:\

I’ve followed the “Installing ROS 2 on Linux” tutorial [..]

which one? Always include a link.

Comment by Dirk Thomas on 2020-06-20:
In the future a much more helpful error message should be shown: https://github.com/ros2/rclpy/pull/580


1 Answer 1


Rosanswers logo

your stack trace looks extremely suspect to me, it looks as if you built ros2 with python3.8 but it seems you're in a conda environment that is using python3.7? I may be wrong about the environment, but you definitely want to make sure you're using a single python version

If we look at the last two lines of the stack trace

File “/home/moutalib/anaconda3/lib/python3.7/importlib/ init .py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named ‘rclpy._rclpy’

The python 3.7 importlib is going to be looking in all of the python3.7 install paths for rclpy, but it will not find it because rclpy was installed with python3.8

Originally posted by johnconn with karma: 553 on 2020-06-18

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by BadrMt on 2020-06-19:
Hello, Thank you for your response. Can you tell me what to do in order to have a single python version ? Should i uninstall conda ?

Comment by johnconn on 2020-06-19:
make sure your conda environment is deactivated using the command conda deactivate. Then things should work. Unfortunately up to ros2 eloquent (and I assume foxy) the build system will only ever look at your system python, and wouldn't work with virtual environments or conda.

Comment by BadrMt on 2020-06-20:
Thank you very much. This solve dmy problem and made me realise an important detail that i was missing about why did i have (base) written before my terminal line.

Comment by johnconn on 2020-06-20:
i'm glad we could get this resolved! Could you click the checkmark to indicate this answer solved your issue?

Comment by dm on 2021-10-02:
I have the same issue but when I type conda deactivate, it says that conda: command not found Can you help me with this?

Comment by Roy Lim on 2023-07-10:
check ~/.bashrc if conda command is allowed


Your Answer

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