运行节点时出现No module named "numpy"
-
如题,楼主的ubuntu安装在win11的wsl2上,
numpy是安装在win系统中的,
但是根据AI,一般来说ros2调用numpy,会直接链接到ubuntu之外的numpy即win上的那个。
然后楼主根据AI的建议,重新设置了这个链接。楼主问AI结果如下:
重新设置的代码如下。
起因:楼主正在学小鱼教程里手搓python节点的练习,colcon和source都正常,也已经安装了numpy,但是ros2 run 的时候报错。报错内容如下。
ros2 run village_li li4_node
Traceback (most recent call last):
File "/root/town_ws/install/village_li/lib/village_li/li4_node", line 33, in <module>
sys.exit(load_entry_point('village_li==0.0.0', 'console_scripts', 'li4_node')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/town_ws/install/village_li/lib/python3.12/site-packages/village_li/li4.py", line 7, in main
li4_node = Node('li4') # 创建节点
^^^^^^^^^^^
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/node.py", line 240, in init
self._parameter_service = ParameterService(self)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/parameter_service.py", line 35, in init
node.create_service(
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/node.py", line 1725, in create_service
check_is_valid_srv_type(srv_type)
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/type_support.py", line 51, in check_is_valid_srv_type
check_for_type_support(srv_type)
File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_or_srv_type.class.import_type_support()
File "/opt/ros/jazzy/lib/python3.12/site-packages/rcl_interfaces/srv/_describe_parameters.py", line 527, in import_type_support
_describe_parameters.Metaclass_DescribeParameters_Event.import_type_support()
File "/opt/ros/jazzy/lib/python3.12/site-packages/rcl_interfaces/srv/_describe_parameters.py", line 341, in import_type_support
from service_msgs.msg import ServiceEventInfo
File "/opt/ros/jazzy/lib/python3.12/site-packages/service_msgs/msg/init.py", line 1, in <module>
from service_msgs.msg._service_event_info import ServiceEventInfo # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/jazzy/lib/python3.12/site-packages/service_msgs/msg/_service_event_info.py", line 18, in <module>
import numpy # noqa: E402, I100
^^^^^^^^^^^^
ModuleNotFoundError: No module named 'numpy'
[ros2run]: Process exited with failure 1希望各位大神帮帮忙呀!小仙什么都会做的(跪