Today we have released the first preview of our next update to Visual Studio 2017. You will see a notification in Visual Studio within the next few days, or you can download the new installer from visualstudio.com.
In this post, we're going to take a look at some of the new features we have added for Python developers. As always, the preview is a way for us to get features into your hands early so you can provide feedback and we can identify issues with a smaller (and hopefully more forgiving!) audience. If you encounter any trouble, please use the Report a Problem tool to let us know.
Immediate IntelliSense updates with no database
Remember how every time you installed or updated a package we would make you wait for hours while we "refresh" our "completion DB"? No more! In this update we are fundamentally changing how we handle this for installed Python environments, including virtual environments, so that we can provide IntelliSense immediately without the refresh.
This has been available as an experimental feature for a couple of releases, and we think it's ready to turn on by default. When you open the Python Environments window, you'll see the "IntelliSense" view is disabled and there is no longer a way to refresh the database -- because there is no database!
The new system works by doing lightweight analysis of Python modules as you import them in your code. This includes .pyd files, and if you have .pyi files alongside your original sources then we will prefer those (see PEP 484 for details of .pyi files. In essence, these are Python "include" files for editors to obtain information about Python modules, but do not actually have any code in them - just function stubs with type annotations).
You should notice some improvements in IntelliSense for packages like pandas and scikit-learn, though there will likely be some packages that do not work as well as before. We are actively working on improving results for various code constructs, and you will also see better IntelliSense results as packages start including .pyi type hint files. We encourage you to post on this github issue to let us know about libraries that still do not work well.
(NOTE: If you install this preview alongside an earlier version of Visual Studio 2017, the preview of this feature will also be enabled in earlier version. You can go back to the old model by disabling the feature in Preview. To do this, open Tools, Options, find the Python/Experimental page, deselect "Use new style IntelliSense" and restart both versions of Visual Studio.)
If you use Anaconda, you likely already manage your environments and packages using the conda tool. This tool installs pre-built packages from the Anaconda repository (warning: long page) and manages compatibility with your environment and the other packages you have installed.
For this preview of Visual Studio, we have added two experimental options to help you work with Anaconda:
- Automatically detect when conda is a better option for managing packages
- Automatically detect any Anaconda environments you have created manually
To enable either or both of these features, open Tools, Options, find the Python/Experimental page, and select the check box. For this preview we are starting with both disabled to avoid causing unexpected trouble, but we intend to turn them on by default in a future release.
With "Automatically detect Conda environments" enabled, any environments created by the conda tool will be detected and listed in the Python Environments window automatically. You can open interactive windows for these environments, assign them in projects or make them your default environment.
With the "Use Conda package manager when available" option enabled, any environments that have conda installed will use that for search, install and updating instead of pip. Very little will visibly change, but we hope you'll be more successful when adding or removing packages to your environment.
Notice that these two options work independently: you can continue to use pip to manage packages if you like, even if you choose to detect environments that were created with conda. If you are an Anaconda user, you will likely want to enable both options. However, if you do this and encounter issues, disabling each one in turn and then reporting any differences will help us quickly narrow down the source.
We have made a range of other minor improvements and bug fixes throughout all of our Python language support and there are more to come.
Our "IPython interactive mode" is now using the latest APIs, with improved IntelliSense and the same module and class highlighting you see in the editor.
There are new code snippets for the argparse module. Start typing "arg" in the editor to see what is available.
We've also added new color customization options for docstrings and regular expression literals (under Tools, Options, Fonts and Colors). Doc strings have a new default color.
If you encounter any issues, please use the Report a Problem tool to let us know (this can be found under Help, Send Feedback) or continue to use our github page. Follow our blog to make sure you hear about our updates first, and thanks for using Visual Studio!