Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code - How to add multiple paths to python path?

I am experimenting with Visual Studio Code and so far, it seems great (light, fast, etc).

I am trying to get one of my Python apps running that uses a virtual environment, but also uses libraries that are not in the site-package of my virtual environment.

I know that in settings.json, I can specify a python.pythonPath setting, which I have done and is pointing to a virtual environment.

I also know that I can add additional paths to python.autoComplete.extraPaths, where thus far I am adding the external libraries. The problem is, when I am debugging, it's failing because it's not finding the libraries specified in python.autoComplete.extraPaths.

Is there another setting that must be used for this?

Thanks

like image 474
mike01010 Avatar asked Jan 04 '17 19:01

mike01010


1 Answers

This worked for me:-

in your launch.json profile entry, specify a new entry called "env", and set PYTHONPATH yourself.

"configurations": [     {         "name": "Python",         "type": "python",         "stopOnEntry": false,         "request": "launch",         "pythonPath": "${config.python.pythonPath}",         "program": "${file}",         "cwd": "${workspaceRoot}",         "debugOptions": [             "WaitOnAbnormalExit",             "WaitOnNormalExit",             "RedirectOutput"         ],         "env": {             "PYTHONPATH": "/path/a:path/b"         }     } ] 
like image 136
malbs Avatar answered Sep 28 '22 23:09

malbs