What’s new for Python in Visual Studio 2017 15.6 Preview 1


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

Before and after images of the IntelliSense pane of the Python Environments window

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).

Completions in the editor from the pandas package

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.)

conda integration

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

Install package from conda in the Python environments window

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.

Options dialog with experimental conda options highlighted

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.

Other improvements

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.

Interactive window showing current jupyter_client version and improved syntax highlighting

There are new code snippets for the argparse module. Start typing "arg" in the editor to see what is available.

In the editor adding an argparse snippet.

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.

Doc strings and regex literal strings with customized colors

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!


Comments (6)
  1. W Stephens says:

    Hey! I am new to Python within Visual Studio (installed the Anaconda stuff yesterday), and noticed that the Anaconda Prompt has an incomplete Target in its properties — and so does the Jupyter Notebook shortcut.

    This is the Target in the Anaconda Prompt properties:

    “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\pythonw.exe” “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\cwp.py” “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64” %windir%\system32\cmd.exe “/K” “C

    And this is the Target in the Jupyter Notebook properties:

    “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\pythonw.exe” “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\cwp.py” “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64” “C:/Program Files (x86)/Microsoft

    Both seem to work though. 😉

    It’s just that I was trying to get Jupyter to save/open files on a network drive and cannot figure out how to get out of “C:”!!! I thought that I could modify something in the Target parameters, say, a startup folder? Some command-line help somewhere could help.

    Thanks.

    1. This looks like an issue in the Anaconda installer. I’ll pass it on to them – it shouldn’t affect anything within Visual Studio.

      1. W Stephens says:

        Hmm… yes, I suppose that could be.

        Thanks.

  2. محصولات ferrarucci says:

    Hi
    I have a VS2015 C# solution with python project in it, Now I upgraded visual studio to “2017 community preview” version. I can’t open it in the new version. whenever I tried the error pop up and said incompatible is there any way i can fix this and run my python project?
    P.S:
    new version is still really really heavy my laptop scream when I open VS can u please make it lighter next time 😀
    thanks

    1. We should automatically update the Python project to work correctly when you open it. If this is not happening, try opening the project on its own. Or else please use the “Report a Problem” tool in Visual Studio and let us know that way – reporting issues on blogs is awkward as they never end up in our issue tracking system.

  3. Jose Ortiz says:

    Hi Steve,
    Wanted to share my experience with Python Tools (PTVS) as a frequent user; I hope my comment can steer development, as my success as a developer hinges greatly on the performance of PTVS.

    Update 15.4, as we now know, broke many of the functionalities of PTVS, as I and others documented on Github. Since then, I’ve been updating my VS 2017 periodically, comparing each new release to the reliability found Visual Studio 2015’s older version of PTVS. Since then, I have not found the experience satisfactory – Intellisense, highlighting, and more has not been as reliable as 2015’s since VS2017 15.4.

    I know there are a lot of new developments, fundamental changes in the databases, etc. In the future, I hope these types of fundamental changes do not get incorporated into the released product until they are solid.

    Because VS2017 does not let the user choose the installed version, users are stuck with whatever changes get pushed into the release. Therefore, it is critical that the released changes are solid – that all highlighting, module recognition, and most basic features are working very reliably; speed and efficiency are really secondary concerns.

    So for now, I continue to use VS2015. It might be less efficient, slower, but it is the only currently-available version of PTVS that is solid, that has all the basic PTVS functionalities I have come to love working, and reliably so. I hope in the future I will feel the same way about VS 2017.

    Thanks.

Comments are closed.

Skip to main content