Problem:
I’m trying to use VSCode to develop a Slicer extension. This is my first time using Slicer. I am trying to set up my development environment such that the code has typical autocomplete functions. I am using Ubuntu 22.04.1 LTS and VSCode version 1.74.0 5235c6bb189b60b01b1f49062f4ffa42384f8c91 x64. My Slicer version is 5.2.1-linux-amd64
Similar Topics:
Here are the other topics I’ve looked at, but neither solved my issue.
Developing Slicer modules in Visual Studio / Visual Studio Code? (slightly out of date as pythonPath is not part of the settings.json file anymore).
What I’ve tried:
I’ve selected the Python contained in Slicer.
I then went into the integrated python console of the slicer gui and ran:
slicer.util.pip_install(‘pylint rope autopep8’)
My workspace settings.json file in .vscode is as follows. I have verified that this file is in the correct location.
{
"python.autoComplete.extraPaths": [
"/opt/Slicer-5.2.1-linux-amd64/",
"/opt/Slicer-5.2.1-linux-amd64/lib/",
"/opt/Slicer-5.2.1-linux-amd64/lib/Python",
"/opt/Slicer-5.2.1-linux-amd64/lib/QtPlugins",
"/opt/Slicer-5.2.1-linux-amd64/lib/Slicer-5.2",
"/opt/Slicer-5.2.1-linux-amd64/bin",
],
"python.linting.pylintPath": "/opt/Slicer-5.2.1-linux-amd64/lib/Python/bin/pylint",
"python.analysis.extraPaths": [
"/opt/Slicer-5.2.1-linux-amd64/",
"/opt/Slicer-5.2.1-linux-amd64/lib/",
"/opt/Slicer-5.2.1-linux-amd64/lib/Python",
"/opt/Slicer-5.2.1-linux-amd64/lib/QtPlugins",
"/opt/Slicer-5.2.1-linux-amd64/lib/Slicer-5.2",
"/opt/Slicer-5.2.1-linux-amd64/bin"
],
"python.linting.enabled": true,
"python.formatting.autopep8Path": "/opt/Slicer-5.2.1-linux-amd64/lib/Python/bin/autopep8",
}
After doing this, I would expect to be able to have VSCode autocomplete/provide suggestions on modules etc. However:
I do have the suggestions when importing however, suggesting vscode is indeed pointing to the correct Python launcher:
I have also tried copying the above settings.json file to the user settings.json file, but to no avail.