Home > Net >  How to set PYTHONPATH for all tools in Vscode (on Windows)?
How to set PYTHONPATH for all tools in Vscode (on Windows)?

Time:03-02

I have a folder mysrc in my project root and I'd like to make all tools of VScode work with import mysrc. The only way I found to make it work is to put the full absolute path PYTHONPATH=<fullpath_to_workfolder> in the .env file. But ideally I'd like to use relative paths to the workfolder.

How can I do that?

All suggestions I found (also here) somehow do not work. ${workspaceFolder} is empty. PYTHONPATH=. does not work. Ideally I'd configure a single PYTHONPATH and not for every tool (terminal, notebooks, mypy, ...). And even my solution for whatever reason duplicates PYTHONPATH=<fullpath_to_workfolder>;<fullpath_to_workfolder> on Windows when I inspect this variable in my code. I believe on Linux I did not have issues.

CodePudding user response:

I'm not sure if this is what you want, but you could create a batch file with the following lines:

@echo off
set PYTHONPATH=           
  • Related