cyberbotics / webots

Webots Robot Simulator
https://cyberbotics.com
Apache License 2.0
3.19k stars 1.67k forks source link

ImportError: cannot import name 'Robot' from 'controller' #6545

Open A01752228 opened 4 months ago

A01752228 commented 4 months ago

Describe the Bug I have a problem when I want to run the executable .py on the launch. I'm currently working on ROS and when I try to run the launch it says that the library Robot cannot be imported

Traceback (most recent call last): File "/home/user/catkin_ws/src/webots_ros/controllers/drive_1/drive_1.py", line 4, in from controller import Robot ImportError: cannot import name 'Robot' from 'controller' (/home/user/.local/lib/python3.8/site-packages/controller/init.py) [webots_ros_python-3] process has died [pid 9285, exit code 1, cmd /home/user/catkin_ws/src/webots_ros/controllers/drive_1/drive_1.py name:=webots_ros_python log:=/home/user/.ros/log/00039720-08e7-11ef-9ebc-8dc438824077/webots_ros_python-3.log]. log file: /home/user/.ros/log/00039720-08e7-11ef-9ebc-8dc438824077/webots_ros_python-3*.log

lukicdarkoo commented 3 months ago

It looks like it loads the wrong controller library (/home/user/.local/lib/python3.8/site-packages/controller/init.py). There are two possible causes: