2

I cannot find a clear answer on how to define multiple paths for the PYTHONPATH variable. I have tried all possible combinations of different solutions posted on various sites, but none of them work. Why can't this be clearly documented somewhere?

I tried every combination of separator and quoting:

"env": {"PYTHONPATH": "D:\\Users\\path\\a\\"; "D:\\Users\\path\\b\\"},
"env": {"PYTHONPATH": "D:\\Users\\path\\a\\": "D:\\Users\\path\\b\\"},
"env": {"PYTHONPATH": "D:\\Users\\path\\a\\; D:\\Users\\path\\b\\"},
...
2
  • Are you using this launch.json configuration? Commented Oct 8, 2018 at 20:01
  • Yes, this is through launch.json. The error was caused by the space; compare the different between the 3rd line in the question and @shookees answer without the space after the semicolon. Commented Oct 8, 2018 at 21:42

1 Answer 1

3

VSCode's env setting corresponds to operating system's environment variables. Setting settings under the same name would either yield an error or pick one of the values. Here you should use only a single env setting, as well as, set PYTHONPATH once.

In order to use multiple directories, one or more directory pathnames separated by os.pathsep (e.g. colons on Unix or semicolons on Windows)[1]. guessing that your operating system is Windows, the setting would looke like this:

"env": {"PYTHONPATH": "D:\\Users\\path\\a\\;D:\\Users\\path\\b\\"}

[1] - https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.