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

Revision history [back]

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

"ModuleNotFoundError: No module named 'ament_package'"

and

"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 much better 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.

Hope it helps!

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

"ModuleNotFoundError: No module named 'ament_package'"

and

"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 much better 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

Hope it helps!

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

"ModuleNotFoundError: No module named 'ament_package'"

and

"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 much better 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!

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

"ModuleNotFoundError: No module named 'ament_package'"

and

"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 much better more legant 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!

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

"ModuleNotFoundError: No module named 'ament_package'"

and

"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 legant 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!