We are pleased to announce that the September 2018 release of the Python Extension for Visual Studio Code is now available. You can download the Python extension from the marketplace, or install it directly from the extension gallery in Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.
In this release we have closed a total of 45 issues, including:
- Automatic activation of environments in the terminal.
- Support for Python environments in split terminals.
- Debugger support for the breakpoint() built-in.
- Improved Go To Definition and find all references in the Python Language Server.
- Reduced CPU and Memory consumption in the Python Language Server.
Also be sure to check out the September Update to Visual Studio Code, which includes a new custom title and menu bar on windows and the tutorial on how to Use Django in Visual Studio Code.
Automatic Activation of Environments in the Terminal
When you create a new terminal, the extension now automatically activates the selected Python pipenv, conda, pyenv, or virtual Environment so that you can run python and pip/conda commands. In the below screenshot we have the 'env' virtual environment selected (as indicated in the status bar) and then created a new terminal using Terminal > New Terminal (Ctrl+Shift+`), and the virtual environment is activated automatically when the terminal is created:
You no longer need to use the Python: Create Terminal command to create an activated Python terminal (terminals with a Python environment activated).
It is also possible to use activated Python terminals in split terminal mode. The extension uses the selected Python environment at the time the terminal is created, so if you want to have terminals with two different environments activated, you can change your environment and create a new terminal.
The screenshot below shows two different Python environments side-by-side terminals, resulting from clicking on the Python interpreter in the status bar and changing it to 'otherenv' and then clicking the split icon in the terminal:
The extension now shows the name of the environment in the status bar, making it easy to determine which environment is active if you have multiple environments in your workspace.
If you are not seeing your environment selected, you may need to first open a Python file to load the Python extension, or if the terminal was created before an environment was selected you may need to create a new terminal. Note that global interpreters do not get activated in terminals, so you'll need to run those using e.g. python3 (Linux/macOS) or py -3 (Windows).
Debugger Improvements
The debugger now supports the breakpoint() built-in in Python 3.7. If you are on Python 3.7 you can add a breakpoint() call, and the debugger will automatically stop on that line when it is hit (you must already be running under the debugger for this functionality; it will not launch the debugger automatically for you).
In the below example the debugger stops on a breakpoint() call inside of a Django view: