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

import numpy error in geometry_msg in setting-robot simulation tutorial

asked 2022-01-14 18:02:19 -0500

pablo.arandarod gravatar image

When I was trying the tutorial setting-up a robot simulation setting-up a robot simulation and I encountered an error that I'm not being sure on how to solve since it seems that it is unable to find numpy in the site-packages of the python inside the ros/foxy installation. The error that I find is:

[driver-2] Traceback (most recent call last):
[driver-2]   File "/home/pablo/dev_ws/install/my_package/lib/python3.8/site-packages/my_package/my_robot_driver.py", line 2, in <module>
[driver-2]     from geometry_msgs.msg import Twist
[driver-2]   File "/opt/ros/foxy/lib/python3.8/site-packages/geometry_msgs/msg/__init__.py", line 3, in <module>
[driver-2]     from geometry_msgs.msg._accel_with_covariance import AccelWithCovariance  # noqa: F401
[driver-2]   File "/opt/ros/foxy/lib/python3.8/site-packages/geometry_msgs/msg/_accel_with_covariance.py", line 9, in  <module>
[driver-2]     import numpy  # noqa: E402, I100
[driver-2] ModuleNotFoundError: No module named 'numpy'
[driver-2] terminate called after throwing an instance of 'std::runtime_error'
[driver-2]   what():  The my_package.my_robot_driver.MyRobotDriver plugin cannot be found (C++ or Python).
edit retag flag offensive close merge delete

Comments

I have seen this error before with Webots: Try pip3 install numpy. Let me know if it works, then I will document as an answer.

osilva gravatar image osilva  ( 2022-01-14 18:35:03 -0500 )edit

Sorry shouldn’t be recommending pip3, try this first: sudo apt install python3-numpy

osilva gravatar image osilva  ( 2022-01-15 05:43:14 -0500 )edit

@pablo.arandarod did you try?

osilva gravatar image osilva  ( 2022-01-19 12:47:37 -0500 )edit
1

@osilva yes, and also having it installed in other environments and did not worked. I reinstalled ros foxy, so once I have time again I will go into it (hopefully this weekend)

pablo.arandarod gravatar image pablo.arandarod  ( 2022-01-20 07:18:28 -0500 )edit

@osilva I just tried it and I can confirm that by installing ros thorugh apt the tutorial works. I don't know if there is some dependency or anything that isn't working as it should when I built it, but at least it works if I install it.

pablo.arandarod gravatar image pablo.arandarod  ( 2022-01-20 15:39:16 -0500 )edit

Thank you @pablo.arandarod. Let me document as an answer

osilva gravatar image osilva  ( 2022-01-20 16:22:53 -0500 )edit

@osilva I don't know exactly how to do it from here, I'm a bit new to this.

pablo.arandarod gravatar image pablo.arandarod  ( 2022-01-21 02:32:26 -0500 )edit

Hi @pablo.arandarod, if you arrive to a solution, it's good practice to document by summarizing the problem encountered and the resolution in the form of an answer. You can respond to your own questions as well. To accept the answer, please click on the checkmark and vote up if the advice was helpful to increase karma. Increasing karma motivates answerers to continue helping, so it's good practice.

osilva gravatar image osilva  ( 2022-01-21 08:14:28 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2022-01-21 08:10:49 -0500

osilva gravatar image

In the event of the following error: ModuleNotFoundError: No module named 'numpy'

This error indicates numpy library is not installed as a dependency for Python 3.

To resolve:

sudo apt install python3-numpy

If you use pip3 (not recommended)

pip3 install numpy
edit flag offensive delete link more

Question Tools

Stats

Asked: 2022-01-14 18:02:19 -0500

Seen: 51 times

Last updated: Jan 21 '22