import numpy error in geometry_msg in setting-robot simulation tutorial
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).
Asked by pablo.arandarod on 2022-01-14 19:02:19 UTC
Answers
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
Asked by osilva on 2022-01-21 09:10:49 UTC
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.Asked by osilva on 2022-01-14 19:35:03 UTC
Sorry shouldn’t be recommending
pip3
, try this first:sudo apt install python3-numpy
Asked by osilva on 2022-01-15 06:43:14 UTC
@pablo.arandarod did you try?
Asked by osilva on 2022-01-19 13:47:37 UTC
@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)
Asked by pablo.arandarod on 2022-01-20 08:18:28 UTC
@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.
Asked by pablo.arandarod on 2022-01-20 16:39:16 UTC
Thank you @pablo.arandarod. Let me document as an answer
Asked by osilva on 2022-01-20 17:22:53 UTC
@osilva I don't know exactly how to do it from here, I'm a bit new to this.
Asked by pablo.arandarod on 2022-01-21 03:32:26 UTC
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.
Asked by osilva on 2022-01-21 09:14:28 UTC