1. 先配置pycharm的Poject Structure
打开Pycharm --> File --> Settings --> Project:项目名 --> Project Structure --> +Add Content Root,添加上会用到的库
- /opt/ros/melodic/lib/python2.7/dist-packages
- /usr/local/webots/lib/controller/python39
- /home/xx/multi-robot-data-collection
2. 再配置LD_LIBRARY_PATH
Edit Configurations... --> Environment variables: --> LD_LIBRARY_PATH=/usr/local/webots/lib/controller
3. 在代码里
sys.path.append('/usr/local/webots/lib/controller/python39')
sys.path.append('/opt/ros/melodic/lib/python2.7/dist-packages')
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
- /usr/local/webots/lib/controller/python39