ROS Python Module - Autocompletion doesn't work when self-compiled
Hey,
i have written a package with an python module in it. I can import it in my other packages but VSCode cannot autocomplete functions.
from <ros_python_module> import <class>
when i click on <ros_python_module>, it goes into an autogenerated "_ _init__.py" inside of my devel folder. There is no code from me.
# -*- coding: utf-8 -*-
# generated from catkin/cmake/template/__init__.py.in
# keep symbol table as clean as possible by deleting all unnecessary symbols
Is it possible that catkin build makes a copy of the files and moves them into the devel folder?
Example: moveit_commander -> from package manager i can autocomplete inside vscode --> compiling by myself and it doesnt autocomplete
VSCode needs to know where the actual code is. You probably need to edit the configuration file of VSCode or use a plugin that knows where to look for python code in ROS packages and does this for you. Copying the files to where VSCode is now looking doesn't sound like a good idea.
VSCode knows the PYTHONPATH but how i said, catkin compiles an auto generated init py which is not introspecteable :/
Hi Tobi, I'm having the same problem: even though import works, I can't get autocomplete on my IDEs (PyCharm or VSCode) for my custom source modules. I'm wondering if you found a solution for this?
@vbs you have to add the folder to your vscode settings.json. "python.autoComplete.extraPaths"
Is that the package folder? I added it like this but made no difference:
"python.autoComplete.extraPaths": [ "/home/vbs/catkin_ws/src/test_python_import/src/test_python_import" ]
extraPaths should point to the folder that contains a folder with __init__.py file. In my case it was: