I have a Python project and navigation/autocomplete work perfectly within files in the project. I want to specify a virtualenv so that navigation/autocomplete work with packages inside that virtualenv.
I tried this in settings.py, but navigation/autocomplete does not work. Also by setting "python.pythonPath":"~/dev/venvs/proj/bin/python
killed the original navigation/autocomplete.
{ "editor.rulers": [80,100], "python.autoComplete.extraPaths": [ "~/dev/venvs/proj", "~/dev/venvs/proj/lib" ] }
With the latest update to the extension all you need to do is just specify the "python.pythonPath"
as follows.
The values for "python.autoComplete.extraPaths"
will be determined during runtime, but you are still free to specify custom paths in there.
Please, remember to restart Visual Studio Code once the necessary changes have been made.
{ "editor.rulers": [80,100], "python.pythonPath":"~/dev/venvs/proj/bin/python" }
As of September 2016 (according to the GitHub repository documentation of the extension) you can just execute a command from within Visual Studio Code that will let you select the interpreter from an automatically generated list of known interpreters (including the one in your project's virtual environment).
How can I use this feature?
- Select the command
Python: Select Workspace Interpreter
(*) from the command palette (F1).
- Upon selecting the above command a list of discovered interpreters will be displayed in a
quick pick
list.
- Selecting an interpreter from this list will update the settings.json file automatically.
(*) This command has been updated to Python: Select Interpreter
in the latest release of Visual Studio Code (thanks @nngeek).
Also, notice that your selected interpreter will be shown at the left side of the statusbar, e.g., Python 3.6 64-bit. This is a button you can click to trigger the Select Interpreter feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With