1 min read

How to make VSCODE understand Python in a non-pythonic repo

Like redirections to code by ctrl + left click or showing all class/function usage in the code base.

Firstly install VSCODE extensions for Python, probably Python, Python Extended , Python Extension Pack and/or Pylance. Not sure which one, but they don't look like are in conflict with each other.

Ctrl + p, then type "Settings" and you get 2 options:
- Preference: Open User Settings (JSON)
- Preference: Open Remote Settings (JSON) (SSH: {hostname})

Choose a settings.json for which you want to make the change and add/extend these sections:

...
"launch": {
      "configurations": [{
          ...
          "env": {
              "PYTHONPATH": "pythonpath1:pythonpath2"
          }
      }],
      ...
    },
...
"python.analysis.extraPaths": [
        "./path_without_python_code",
        "./path_without_python_code2",
        ...
    ],
...

Restart, refresh or do nothing and see which one eventually understood the paths you added:)