2

Is it possible to automate or relocate a launch.json setting to the user settings so I do not have to edit the same line in each launch.json?

I have many Python modules in a directory outside of the Python Path and currently am having to edit each launch.json file to add the following line:

"env": {"PYTHONPATH": "\\my\\custom\\path"}

I tried adding the following line to User Settings, but it did not work:

"python.envFile": "\\path\\to\\python\\env\\file"

where the *.env contains the following:

"PYTHONPATH": "\\my\\custom\\path"

VScode I can open any python file that import from a custom path, right click and run it through VScode - I assume VScode is calling the native Python interpreter and seeing the PYTHONPATH environment variable.

Some Python environments (Spyder, PyCharm, etc) have a global setting for this, but I do not know how to accomplish this in VScode. Note VScode is consistent with PTVS; I have to edit the Search Paths for each Python solution in Visual Studio.

pyuser00
  • 61
  • 2
  • 7
  • 1
    I believe the `.env` files take the format of `ENV=value`, so try it again with `PYTHONPATH=path`. – Brett Cannon Jan 08 '18 at 20:10
  • I tried that, following the current [docs](https://code.visualstudio.com/docs/python/environments) following the [request](https://github.com/Microsoft/vscode-python/issues/544), but still cannot get it to work. – pyuser00 Dec 06 '18 at 20:43
  • what if you add that custom path to the workspace settings, e.g., `"python.pythonPath": "/opt/mypath/bin/python3",` – nos Dec 17 '18 at 21:23
  • 1
    This was answered in this thread https://stackoverflow.com/a/53766220/894497 – Festum Oct 20 '20 at 15:30

0 Answers0