Python in Visual Studio Code – April 2021 Release
We are pleased to announce that the April 2021 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. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.
This release includes a preview of support for Poetry environments, improved completions for PyTorch 1.8.1 when using Pylance, as well enhancements to the Data Viewer. You can check the full list of fixes and improvements in our changelog.
Support for Poetry environments
We’re excited to announce our preview support for Poetry environments in Visual Studio Code, the most requested feature in our GitHub repository!
Poetry is a Python package and dependency manager that makes it easy to build, publish your projects, as well as and check the state of its dependencies.
If you’re using our Insiders build, you will be able select interpreters from environments created using Poetry, as they’re now automatically discovered by the Python extension. Once you select it, you can create a new terminal to have that environment automatically activated.
The Python extension will also use Poetry when installing packages on your behalf:
If you want to try this out, you can join our Insiders program by opening the command palette (View > Command Palette…) and run the “Python: Switch to Insiders Weekly Channel”. Once the insiders build finishes downloading, you will be prompted to reload the window.
If you’re using Poetry for the first time, make sure you follow the setup instructions from Poetry’s documentation.
We look forward to bringing this experience to the stable version of the Python extension, so if you try this out and see any issues with it, please file a bug report.
Improved auto-completions for PyTorch 1.8.1 with Pylance
We’re excited to announce that our team spent some time in the last month contributing to the PyTorch project to update how submodules are exported in the top-level torch module. With these changes, Pylance users using PyTorch should update to PyTorch 1.8.1 to get dramatically improved completions for submodules (e.g. nn, optim, cuda).
Data Viewer Enhancements
In case you missed it in the latest release of the Jupyter extension, we’ve made many improvements to our Data Viewer.
Firstly, we have added the ability to refresh the Data Viewer. If you’ve made some changes or transformations to your data, rather than having to close and reopen the Data Viewer to view the changes, you can now click the refresh button in the top corner of the Data Viewer to grab the most up-to-date data.
Secondly, the Data Viewer now supports viewing both PyTorch and TensorFlow Tensor data types!
Thirdly, we’ve given the entire Data Viewer a visual update to make it more aesthetically pleasing. You can now find the filter box at the heading of each column, and you can click into individual cells in the Data Viewer to copy out their contents. You can continue to click on any column heading to sort its data ascending/descending.
Last but not least, the Data Viewer now supports slicing data, which allows you to view any 2D slice of your higher dimensional data. If you have 3-dimensional or greater data (numpy ndarray, PyTorch Tensor or TensorFlow EagerTensor types), you will now be able to view that multi-dimensional data in the Data Viewer and a new data slicing panel will open in the Data Viewer by default. In this panel, you will be able to either use an input box to programmatically specify your slice using Python slice syntax or use the interactive Axis and Index dropdowns to slice as well. Both will be in sync.
Other Changes and Enhancements
We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python in Visual Studio Code. Some notable changes include:
- Deprecate format on type since it isn’t used in newer Language servers. (#15709)
- Remove notification prompt to install pylint by default (#15465)
- Prevent mypy errors for other files showing in current file. (thanks Steve Dignam) (#10190)
- Ensure jedi processes are terminated on language server dispose. (#15644)
- Add a refresh icon next to interpreter list (available in the Insiders build). (#15868)
Be sure to download the Python extension for Visual Studio Code now to try out the above improvements. If you run into any problems or have suggestions, please file an issue on the Python VS Code GitHub page.