Steve Dower, Author at Microsoft for Python Developers Blog https://devblogs.microsoft.com/python/author/stevdo/ Read the latest updates about all things Python at Microsoft Fri, 10 Jun 2022 20:07:01 +0000 en-US hourly 1 https://devblogs.microsoft.com/python/wp-content/uploads/sites/12/2018/10/Microsoft-Favicon.png Steve Dower, Author at Microsoft for Python Developers Blog https://devblogs.microsoft.com/python/author/stevdo/ 32 32 Anaconda licensing for Microsoft products and services https://devblogs.microsoft.com/python/anaconda-licensing/ Mon, 25 Oct 2021 22:06:06 +0000 https://devblogs.microsoft.com/python/?p=8742 Our friends at Anaconda have posted a joint announcement last week regarding the use of their repository from Microsoft cloud-hosted products. See the full announcement on their website. Today, Anaconda, Inc. announced a collaboration with Microsoft to enable customers to confidently access Anaconda’s curated library of open-source packages within Microsoft Cloud-hosted products and services, including […]

The post Anaconda licensing for Microsoft products and services appeared first on Microsoft for Python Developers Blog.

]]>
Our friends at Anaconda have posted a joint announcement last week regarding the use of their repository from Microsoft cloud-hosted products. See the full announcement on their website.

Today, Anaconda, Inc. announced a collaboration with Microsoft to enable customers to confidently access Anaconda’s curated library of open-source packages within Microsoft Cloud-hosted products and services, including Azure services like Azure Machine Learning, as well as GitHub services such as GitHub Codespaces and GitHub Actions, without the requirement of a separate license.1

We are very excited for our customers to continue to have access to Anaconda’s packages across all of our cloud-hosted services, and to make Azure an easy and safe choice for your data science and machine learning work.

Check out each service’s documentation for instructions on using Conda with Anaconda’s packages or your own repository, as the details may vary. This coverage is only for our services where we’ve provided Conda support, and doesn’t include your own custom virtual machines or on-premise deployments.

The post Anaconda licensing for Microsoft products and services appeared first on Microsoft for Python Developers Blog.

]]>
Who put Python in the Windows 10 May 2019 Update? https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/ https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/#comments Tue, 21 May 2019 19:59:27 +0000 https://devblogs.microsoft.com/python/?p=7246 Today the Windows team announced the May 2019 Update for Windows 10. In this post we’re going to look at what we, Microsoft’s Python team, have done to make Python easier to install on Windows by helping the community publish to the Microsoft Store and, in collaboration with Windows, adding a default “python.exe” command to […]

The post Who put Python in the Windows 10 May 2019 Update? appeared first on Microsoft for Python Developers Blog.

]]>
Today the Windows team announced the May 2019 Update for Windows 10. In this post we’re going to look at what we, Microsoft’s Python team, have done to make Python easier to install on Windows by helping the community publish to the Microsoft Store and, in collaboration with Windows, adding a default “python.exe” command to help find it. You may have already heard about these on the Python Bytes podcast, at PyCon US, or through Twitter.

As software moves from the PC to the cloud, the browser, and the Internet of Things, development workflows are changing. While Visual Studio remains a great starting point for any workload on Windows, many developers now prefer to acquire tools individually and on-demand.

For other operating systems, the platform-endorsed package manager is the traditional place to find individual tools that have been customized, reviewed, and tested for your system. On Windows we are exploring ways to provide a similar experience for developers without impacting non-developer users or infringing publishers’ ability to manage their own releases. The Windows Subsystem for Linux is one approach, offering developers consistency between their build and deployment environments. But there are other developer tools that also matter.

One such tool is Python. Microsoft has been involved with the Python community for over twelve years, and currently employ four of the key contributors to the language and primary runtime. The growth of Python has been incredible, as it finds homes among data scientists, web developers, system administrators, and students, and roughly half of this work is already happening on Windows. And yet, Python developers on Windows find themselves facing more friction than on other platforms.

Installing Python on Windows

The Windows command prompt showing an error when Python cannot be foundIt’s been widely known for many years that Windows is the only mainstream operating system that does not include a Python interpreter out of the box. For many users who are never going to need it, this helps reduce the size and improve the security of the operating system. But for those of us who do need it, Python’s absence has been keenly felt.

Once you discover that you need to get Python, you are quickly faced with many choices. Will you download an installer from python.org? Or perhaps a distribution such as Anaconda? The Visual Studio installer is also an option. And which version? How will you access it after it’s been installed? You quickly find more answers than you need, and depending on your situation, any of them might be correct.

We spent time figuring out why someone would hit the error above and what help they need. If you’re already a Python expert with complex needs, you probably know how to install and use it. It’s much more likely that someone will hit this problem the first time they are trying to use Python. Many of the teachers we spoke to confirmed this hypothesis – students encounter this far more often than experienced developers.

So we made things easier.

The header of the Python 3.7 page in the Microsoft Store

First, we helped the community release their distribution of Python to the Microsoft Store. This version of Python is fully maintained by the community, installs easily on Windows 10, and automatically makes common commands such as python, pip and idle available (as well as equivalents with version numbers python3 and python3.7, for all the commands, just like on Linux).

The Windows command prompt showing that "python3.7" now launches Python and "pip3" launches pip

Finally, with the May 2019 Windows Update, we are completing the picture. While Python continues to remain completely independent from the operating system, every install of Windows will include python and python3 commands that take you directly to the Python store page. We believe that the Microsoft Store package is perfect for users starting out with Python, and given our experience with and participation in the Python community we are pleased to endorse it as the default choice.

Scott Hanselman on Twitter: "WHOA. I'm on a new copy of Windows and I typed Python - on a machine where I don't have it - and it launched the Windows Store into an official distribution I can install in a click. WHEN did this happen. I love this."We hope everyone will be as excited as Scott Hanselman was when he discovered it. Over time, we plan to extend similar integration to other developer tools and reduce the getting started friction. We’d love to hear your thoughts, and suggestions, so feel free to post comments here or use the Windows Feedback app.

 

The post Who put Python in the Windows 10 May 2019 Update? appeared first on Microsoft for Python Developers Blog.

]]>
https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/feed/ 70
Introducing the Python Language Server https://devblogs.microsoft.com/python/introducing-the-python-language-server/ Wed, 18 Jul 2018 18:11:36 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=2615 Visual Studio has long been recognized for the quality of its IntelliSense (code analysis and suggestions) across all languages, and has had support for Python since 2011. We are pleased to announce that we are going to be making the Python support available to other tools as the Microsoft Python Language Server. It is available […]

The post Introducing the Python Language Server appeared first on Microsoft for Python Developers Blog.

]]>
Visual Studio has long been recognized for the quality of its IntelliSense (code analysis and suggestions) across all languages, and has had support for Python since 2011. We are pleased to announce that we are going to be making the Python support available to other tools as the Microsoft Python Language Server. It is available first today in the July release of the Python Extension for Visual Studio Code, and we will later release it as a standalone component that you can use with any tool that works with the Language Server Protocol.

Background on IntelliSense and Language Servers

Ever since the days of Visual Basic, one of the core features of the Visual Studio series of IDEs has been IntelliSense: auto-completions for variables, functions, and other symbols that appear as you type in your code. Through a clever combination of static code analysis, precompiled databases and UI overlays, developers are regularly blown away at how productive they can be with an editor that truly understands their code.

IntelliSense being used in Visual Basic 6.0

Fast forward to today, and IntelliSense is still one of the most important features out there. More tools are requiring users to write code, and completions are practically a necessity in these editors. However, writing the static analysis necessary to provide a great experience is difficult, and most implementations are very closely tied to the editor they work with. Enter the language server protocol.

Language servers are standalone programs implementing the language server protocol, and were created to work with Visual Studio Code. Editors can start running a language server and use this JSON-based communication channel to provide and request information about the user’s code. All of the analysis and “smart” operations are handled by the server, allowing the editor to focus on presentation and interaction with the user.

Visual Studio Code uses language servers for most of its supported languages, including C++, C# and Go. From the editor’s point of view there are no differences between these languages – all the intelligence exists in the language server. This means that it is easy to add support for new languages to Visual Studio Code, and it does not require changing the editor at all. Language servers can also be used with plugins for Sublime Text, vim and more.

Introducing the Python Language Server

Previously, Python IntelliSense in Visual Studio was very specific to that IDE. We have been developing this support for nearly a decade. It has an impressively deep understanding of the Python language, but only Visual Studio users have been able to enjoy this work. Recently we have been refactoring our implementation to separate it from Visual Studio and make it available as a standalone program using the language server protocol.

From the point of view of the editor, language servers are a black box that is given text and gives back lists of more text. But the black box normally contains a process known as static type inferencing, where the language server determines (“infers”) the type of each variable without actually running the code. For statically-typed languages, such as C#, this is often as simple as finding the variable definition and the type specified there. However, Python variables can change type any time they are assigned, and assignments can happen almost anywhere in any of the code that is run. This actually makes perfect static type inferencing impossible!

Python IntelliSense in Visual Studio 2017

(Technical aside: Variables are often thought of as “holes” into which only compatible values can “fit”, where the shape of the hole is determined by its type. In Python, variables are names that are attached (“bound”) to the value when it is assigned. Assigning a new name always re-binds the value regardless of whether the type is the same as the previous one. So just because you see “self.value = ‘a string’” in one place doesn’t mean that “self.value” will always be a string.)

Our Python Language Server uses iterative full-program analysis to track the types of all the variables in your project while simulating execution of all the code in your project. Normally this kind of approach can take hours for complex programs and require unlimited amounts of RAM, but we have used many tricks to make it complete quickly enough for IntelliSense use. We have also made the tradeoffs necessary to provide useful information despite it not being possible to perfectly infer all types in a Python program.

The end result is that we have a black box that takes Python code and provides all the information your editor needs for tooltips, completions, finding definitions and references, global variable renaming, and more. For performance, it runs with .NET Core on Windows, macOS and Linux, works with Python 2.5 through to Python 3.7 and supports the latest language features such as async/await, type annotations and type stub packages (including typeshed, a copy of which is included with the language server). It performs incremental updates as you type, and is already proven as a core feature of Visual Studio.

Benefits for Python in VS Code

Python IntelliSense in VS Code

Our July release of the Python extension for Visual Studio Code will include an early version of the Python Language Server. Features that are new for VS Code developers in this release include:

  • Syntax errors as you type in code
  • Warnings when modules are not found
  • Using typeshed files to fill in missing completions for modules
  • Improved performance for analyzing your workspace and presenting completions
  • Ability to detect syntax errors on your entire workspace, rather than just the current file.
  • Faster startup times
  • Faster imports
  • Better handling for a number of language constructs

All of these are already available in Visual Studio 2017 or will be in the next minor update.

Having a standalone, cross-platform language server means that we can continue to innovate and improve on our IntelliSense experience for Python developers in both Visual Studio and Visual Studio Code at the same time.

Be sure to check out our VS Code release announcement for more information. The standalone release of the Python Language Server will follow in the next few months, and will be available under the Apache 2.0 license.

The post Introducing the Python Language Server appeared first on Microsoft for Python Developers Blog.

]]>
Embedding Python in a C++ project with Visual Studio https://devblogs.microsoft.com/python/embedding-python-in-a-cpp-project-with-visual-studio/ https://devblogs.microsoft.com/python/embedding-python-in-a-cpp-project-with-visual-studio/#comments Thu, 14 Jun 2018 14:00:05 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=2375 In this post, we're going to walk through a sample project that demonstrates scripting a C++ application with Python using CPython, PyBind11 and Visual Studio 2017. We show how you can wrap a C++ class with Python and how to use cross-language debugging and type-hints to get a development experience that only Visual Studio can offer.

The post Embedding Python in a C++ project with Visual Studio appeared first on Microsoft for Python Developers Blog.

]]>
Watch the video version of this post on VS Toolbox

Let’s get started

Sinbad the ogre dancing in the Ogre3d game engine

In this post, we’re going to walk through a sample project that demonstrates scripting a C++ application with Python using CPython, PyBind11 and Visual Studio 2017. The sample code is available at github.com/zooba/ogre3d-python-embed and setup instructions are below.

Ogre3d is an open-source game engine written in C++ that has been used in games such as Hob and Torchlight 2. Both the engine and its source code are freely available from their website. For this sample, we have taken one of their character animation demos and extended it with Python. Rather than using the keyboard to move the character around, we can use Python code to call into the C++ functions that control him.

To build and run this sample on your own machine, you will require Visual Studio 2017 with the Python workload, the Python Native Development option, and Python 3.6 32-bit. If you already have Visual Studio 2017, these can be added by launching “Visual Studio Installer” and modifying the existing install.

Note: When you install Python 3.6 32-bit through Visual Studio, it automatically includes debugging symbols. If you install it yourself, you will need to select “Customize installation” and include debugging symbols. If you have already installed it, you can use Programs and Features to modify your install and add debugging symbols.

Clone our repository using git clone --recurse-submodules https://github.com/zooba/ogre3d-python-embed.git or using Team Explorer in Visual Studio. There is a PowerShell script in the root of the repository called get_externals.ps1 that will download and extract the version of the Ogre3d and SDL2 runtimes needed, and will prompt if you are missing either Python 3.6 32-bit or the DirectX redistributables (you can download the latter here, but be aware that this is a very old installer that will offer to install a browser toolbar – feel free to deselect that).

Once everything is installed, open srcPythonCharacter.sln in Visual Studio 2017 and press Ctrl+F5 to build and run the sample. While running, the sample will capture your mouse cursor, but you can use Alt+Tab to switch to another window. We will do that next to look at some of the code.

In Visual Studio, open Solution Explorer and then open the following files. We will be looking at each in the next few sections.

  • ogre.pyi
  • ogre_module.h
  • SinbadCharacterController.h
  • ai.py

Modifying without recompiling

Simple Python list containing dance, stand, and more steps

The Python module ai.py is where we define the behavior of Sinbad, our dancing ogre. Collapse the command definitions region by clicking the “-” symbol to the left of #region Command definitions and look at the SCRIPT variable. Each item in this list is the movement we want Sinbad to do, including the amount of time he should do it for. There are already some extra movements listed but commented out, so try uncommenting them or adding your own. You can do this while the demo is running in the background.

Once you’ve made changes, save this file, use Alt+Tab to go back to the running sample, and press F5. The F5 key will reload the script, and you will see your changes (or an error) immediately. Compare this to normal C++ development, where you would have had to stop running, modify the code, recompile (and wait!), start running again, and return to the same state you were previously.

This is possible because of CPython’s support for embedding, and made simple by the powerful pybind11 library. Embedding allows you to host the Python runtime in any native application, on any platform and using any compiler supported by CPython. So rather than launching “python.exe” with a script, you can load python36.dll into your own application and use it directly.

It is very easy to make Python representations of your C++ classes with pybind11. Switch to the ogre_module.h file to see what we did for this sample.

Exposing a C++ class to Python using the pybind11 library

This file defines the mapping between a Python module named “ogre” and the classes and functions we want to make available. Using the metaprogramming features added in C++11, the pybind11 library automatically generates code to do the type conversions necessary to make Python code transparently interact with your C++ code. If you switch back to ai.py, you will see that the ogre.CharacterController class is imported and used in Python code to call back into C.

But how can we be sure that it is really doing all this? It seems pretty magical, and barely enough work on our part to make a game engine suddenly support Python scripting. In the next section, we will look at the proof that it is doing what we claim.

Debugging Python and C++

If you’ve got the demo running, now is the time to exit it by clicking on the Stop Debugging button. Visual Studio is famous for its debugging features, and this one is pretty cool. When you installed the Python Native Development option, we included the ability to do mixed Python/C++ debugging, whether you’re in a Python project or a C++ project. You can find information about doing this from Python project in our documentation, but in this case we are going to launch a C++ project with Python debugging enabled.

Selecting Python/Native Debugging from the dropdown in Visual Studio 2017

Find the Start debugging button on the toolbar. Depending on your settings and the file you have open, it be labelled “Start”, “Local Windows Debugger”, “Python/Native Debugging” or “Attach…”. Clicking the small down arrow next to the button will display your options.

Select “Python/Native Debugging” here to make it your new default. All the settings required to make the sample correctly load are already configured for this project (see this page for the details), so you can now press F5 to launch the sample again, but this time with the debugger attached.

Debugging Python and C++ simultaneously in Visual Studio 2017

Open ai.py again and set a breakpoint in the on_frame function near the end of the file. This function is called for each frame, but normally returns quickly until it’s time to run the next step in the script. So while the demo is running, sooner or later this function will be hit. When it is, you’ll see a mixed call stack showing both Python and C++ frames. (In this screenshot, I’ve hidden external code, so you may see some extra frames from pybind11.)

As you press F11 to step through the code, you will jump between Python and C++ just as naturally as either language on its own, and anywhere you view a Python object you’ll be able to see the regular Python view. Breakpoints set in native code or Python code will be hit, and switching up and down the call stack will let you view both kinds of frames.

Type hints for Python code

Finally, let’s take another look at the Python code and how Visual Studio helps you be a productive developer. In general, when you have defined a Python class in C++ you are not going to get IntelliSense when editing the code using it. This is unfortunate, as IntelliSense is most useful when using code that does not have easily read sources, but we now have the ability to provide IntelliSense separately.

Snippet from the type stub file defining ogre.CharacterController

Open the ogre.pyi file. While it looks very much like Python code, it’s actually a type stub file that exists solely for its type hints. We include class and function definitions, but no bodies. With function annotations, we can specify the expected types and the return type of each function, and we will also extract and present documentation strings.

As this file is named ogre.pyi, when the ai.py module imports the native ogre module, IntelliSense will import the type stub instead. Without the type stub, we would not be able to resolve the ogre module at all, as it is generated at runtime by pybind11 and there is no other way for us to find it.

Switch back to ai.py and find the on_frame function. As this is called from C++, we have no information about the arguments that are passed to it, so to get IntelliSense we use type annotations to specify the parameter types. If you start typing character. within this function then you will see all the members that were specified in the type stub.

Python IntelliSense through a type stub file

While this is very convenient and necessary in some situations, most of the time we are able to show you good IntelliSense without needing type hints. If you hover over command in this function you will see all the possible command types; using Go To Definition (F12) on command.execute will take you to either of the implementations of that function; and even though there are no type hints on these functions, we are still able to provide all the completions on character through our type analysis engine. Type stub files are useful for when you want to provide users with IntelliSense for code that cannot be automatically analyzed, and annotations can fill in the gaps that occur when using complex or unusual Python code.

Summary

If you develop native applications that have frequently-changing logic or business rules, it is easy to move that logic from C or C++ into Python, where it can be easily modified and updated without needing to recompile or restart your application. The combination of Visual Studio 2017 with the official CPython releases and pybind11 is the most productive way to develop and debug all aspects of your hybrid C++ and Python project. Download the free Visual Studio 2017 Community to get started today.

The post Embedding Python in a C++ project with Visual Studio appeared first on Microsoft for Python Developers Blog.

]]>
https://devblogs.microsoft.com/python/embedding-python-in-a-cpp-project-with-visual-studio/feed/ 3
North Bay Python 2017 Recap https://devblogs.microsoft.com/python/north-bay-python-2017-recap/ Tue, 12 Dec 2017 18:00:38 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=1726 Last week I had the privilege to attend the inaugural North Bay Python conference, held in Petaluma, California in the USA. Being part of any community-run conference is always enjoyable, and to help launch a new one was very exciting. In this post, I’m going to briefly tell you about the conference and help you […]

The post North Bay Python 2017 Recap appeared first on Microsoft for Python Developers Blog.

]]>
Bliss, the default background from Windows XP

Last week I had the privilege to attend the inaugural North Bay Python conference, held in Petaluma, California in the USA. Being part of any community-run conference is always enjoyable, and to help launch a new one was very exciting. In this post, I’m going to briefly tell you about the conference and help you find recordings of some of the best sessions (and also the session that I presented).

Petaluma is a small city in Sonoma County, about one hour north of San Francisco. Known for their food and wine, it was a surprising location to find a conference, including for many locals who got to attend their first Python event.

If the photo to the right looks familiar, you probably remember it as the default Windows XP background image. It was taken in the area, inspired the North Bay Python logo, and doesn’t actually look all that different from the hills surrounding Petaluma today.

Nearly 250 attendees converged on a beautiful old theatre to hear from twenty-two speakers. Topics ranged from serious topics of web application accessibility, inclusiveness, through to lighthearted talks on machine learning and Django, and the absolutely hilarious process of implementing merge sort using the import statement. All the videos can be found on the North Bay Python YouTube channel.

George London (@rogueleaderr) presenting merge sort implemented using import

Recently I have been spending some of my time working on a proposal to add security enhancements to Python, similar to those already in Powershell. While Microsoft is known for being highly invested in security, not everyone shares the paranoia. I used my twenty-five minute session to raise awareness of how modern malware attacks play out, and to show how PEP 551 can enable security teams to better defend their networks.

Steve Dower (@zooba) presenting on PEP 551

(Image credit: VM Brasseur, CC-BY 2.0)

While I have a general policy of not uploading my presentation (slides are for speaking, not reading), here are the important links and content that you may be interested in:

Overall, the conference was a fantastic success. Many thanks to the organizing committee, Software Freedom Conservancy, and the sponsors who made it possible, and I am looking forward to attending in 2018.

The North Bay Python committee on stage at the end of the conference

Until the next North Bay Python though, we would love to have a chance to meet you at the events that you are at. Let us know in the comments what your favorite Python events are and the ones you would most like to have people from our Python team come and speak at.

The post North Bay Python 2017 Recap appeared first on Microsoft for Python Developers Blog.

]]>
What’s new for Python in Visual Studio 2017 15.6 Preview 1 https://devblogs.microsoft.com/python/whats-new-for-python-in-visual-studio-15-6-preview-1/ Thu, 07 Dec 2017 20:00:32 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=1635 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 […]

The post What’s new for Python in Visual Studio 2017 15.6 Preview 1 appeared first on Microsoft for Python Developers Blog.

]]>
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!

The post What’s new for Python in Visual Studio 2017 15.6 Preview 1 appeared first on Microsoft for Python Developers Blog.

]]>
Python updates in Visual Studio 15.4 Preview 1 https://devblogs.microsoft.com/python/python-updates-in-visual-studio-15-4-preview-1/ Fri, 25 Aug 2017 20:00:31 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=1565 It’s been a while since we last posted, and we’ve been hard at work on new features for Python in Visual Studio 2017. Today, the first preview of the next update has been released, which you can install from visualstudio.com or by updating your existing Preview install. In this post, we’ll briefly discuss the new […]

The post Python updates in Visual Studio 15.4 Preview 1 appeared first on Microsoft for Python Developers Blog.

]]>
It’s been a while since we last posted, and we’ve been hard at work on new features for Python in Visual Studio 2017. Today, the first preview of the next update has been released, which you can install from visualstudio.com or by updating your existing Preview install.

In this post, we’ll briefly discuss the new features in this preview, including the secret tricks and exclusive downloads you will need to enable some of them.

Ctrl+Click Go To Definition

Over the new update you should see this feature coming to most languages in Visual Studio, but we are excited that Python is one of the first to get it.

Ctrl+Click Go To Definition turns identifiers into hyperlinks when you hover over them

You are probably familiar with the Go To Definition feature, either through the editor context menu or the F12 shortcut key, but we have added a new way to use it. While holding the Control key down, the identifier you have the mouse over will turn into a hyperlink if it has definitions you can go to. Clicking on the item will then take you directly to the definition.

Options dialog showing settings that can be changed for Ctrl+Click Go To Definition

If you would prefer to use a key other than Control, the Text Editor options page will let you select an alternative. You can also choose to “peek” the definition rather than going to it, which will open a smaller editor window embedded within the current one.

(Unfortunately, it seems that peek does not work for Python code in this first preview. We’re fixing it for preview 2!)

Debugging in the Windows Subsystem for Linux

Selecting the WSL launcher from a Python project's properties window

The Windows Subsystem for Linux (WSL) is an exciting new technology that lets you use a full Linux distribution on your Windows machine. This is not a virtual machine, but a subsystem similar to the way that 32-bit processes are supported on 64-bit Windows. Follow the link for instructions on how to set it up.

For this preview, we are releasing a separate extension that enables debugging in WSL. After installing this extension, you can select a new debug launcher in Python project properties. Now, when you press F5, your project will launch under WSL using the most compatible version of Python available (for example, a project using Python 3.6 will try to launch with python3.6 and then python3 before returning an error).

Once running, the debugger will automatically attach, providing the great experience you are used to getting with local or remote debugging.

Visual Studio stopped at a breakpoint in Python code running in WSL

One known issue is that you may see an error dialog appear as well as the Bash shell, but your project does not start. In most cases, attempting to launch again should succeed, so please try that before reporting a problem. Also note that native code debugging is not supported with WSL, even though the checkbox for it appears.

You can download the extension from here: Microsoft.PythonTools.Wsl.VS2017.vsix (64 kB)

[Update: 9 March 2018] This version no longer works with Visual Studio 15.6. Please visit this GitHub issue for ongoing discussion and updated downloads.

Warnings: This is a highly experimental extension, and we’re releasing it separately because we may change it dramatically when fully integrated into Visual Studio, or we may decide not to integrate it at all. You may need to manually uninstall the extension before installing future Visual Studio updates. While this extension is completely unsupported, we would love to hear your feedback on GitHub. This download will only be available for a limited time and is only compatible with Visual Studio 15.4 Preview 1.

Debug C++ project with Python

Debugging Python hosted in a C++ executable

If you develop native Python extensions, you are likely familiar with our support for mixed C/Python debugging. Currently, you can only enable this on a Python project, which meant that if you were developing a C++ project that embeds Python, you could not use it.

Today we are releasing a standalone extension that adds a new debugging option to C++ projects: Python native debugging.

Configuring C++ project properties to launch with Python debugging enabled

Selecting this debugger for your C++ project will launch with support for viewing Python types and stack frames, giving you the best experience for debugging your application.

You can download the extension from here: Microsoft.PythonTools.Debugger.VCLauncher.VS2017.vsix (331 kB)

Warnings: This is a highly experimental extension, and we’re releasing it separately because we may change it dramatically when fully integrated into Visual Studio, or we may decide not to integrate it at all. You may need to manually uninstall the extension before installing future Visual Studio updates, and you may require administrative privileges to install and remove it. While this extension is completely unsupported, we would love to hear your feedback on GitHub. This download will only be available for a limited time and is only compatible with Visual Studio 15.4 Preview 1.

Disable the completion database

Completions and documentation for pandas without using a completion DB

Remember when you installed Anaconda and we made you wait hours before giving you IntelliSense? Yeah, we aren’t proud of that. Our IntelliSense is based on some really intense static analysis that infers types for every possible variable, and it takes time to get those results. But in many cases, very simple syntax analysis can provide results that will keep you productive, especially when combined with your own expertise.

So we’ve been working on a brand new approach that does not rely on generating a completion DB. This means that when you install a new environment or a new package, we will give you great IntelliSense immediately, without having to run the background process at all.

This new approach is very experimental right now, and we are actively working on improving the experience. It is included in the current Visual Studio 2017 Preview but disabled by default. You can tell when it is enabled because the IntelliSense dropdown will be missing from the Python Environments window.

Python Environments window before and after disabling the completion DB

To enable this feature, use registry editor to create a key HKEY_CURRENT_USERSoftwareMicrosoftPythonToolsExperimental and add a DWORD value named NoDatabaseFactory and set its value to 1. Then restart Visual Studio.

Warnings: This is a highly experimental feature, and we do not recommend enabling it in production environments. While Visual Studio Preview is not supported, we would love to hear your feedback on GitHub. This registry key is only compatible with Visual Studio 15.4 Preview 1, and newer versions may have alternate.

Enjoy

As usual, feedback is welcome at our GitHub page, and while we don’t recommend using previews in production it is easy to install both the current preview and the current release of Visual Studio 2017 on the same machine.

We hope you enjoy these early previews of our current work. We’re excited about a future with better C++ integration and no IntelliSense database, and we hope you are too. Thanks for being a Visual Studio user!

The post Python updates in Visual Studio 15.4 Preview 1 appeared first on Microsoft for Python Developers Blog.

]]>
PyData Seattle is next week! https://devblogs.microsoft.com/python/pydata-seattle-is-next-week/ Tue, 27 Jun 2017 20:33:02 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=1545 Next week, we’ll be hosting PyData Seattle 2017 at Microsoft. Several hundred attendees, speakers and teachers will converge on our main conference center for three days of talks, tutorials, and other fun. What is PyData? PyData is a regular conference that occurs all around the world multiple times every year. With a focus on data […]

The post PyData Seattle is next week! appeared first on Microsoft for Python Developers Blog.

]]>
Next week, we’ll be hosting PyData Seattle 2017 at Microsoft. Several hundred attendees, speakers and teachers will converge on our main conference center for three days of talks, tutorials, and other fun.

Microsoft Redmond campus. (Stephen Brashear/Getty Images)

What is PyData?

PyData is a regular conference that occurs all around the world multiple times every year. With a focus on data science, and an abundance of Python, it is one of the most relevant conferences in our field at the moment.

Sponsored by NumFOCUS, PyData conferences showcase the latest developments in libraries, tools, practices and services, presented by the developers and practitioners who create and use them. Many significant projects such as Jupyter, NumPy, pandas, Software Carpentry, and more are fiscally supported by NumFOCUS and have a presence at PyData.

How can I join in?

PyData Seattle has an amazing lineup of sessions this year. Registration is still open, but if you can’t make it to Redmond, Washington next week, we have another exciting option.

For the first time in PyData history, we will be livestreaming the keynotes and a selection of sessions during the conference (thanks to the support of the Channel 9 team)!

PyData Seattle 2017, July 6-7

As usual, every session will be recorded and published on YouTube after the conference, but the livestream will have additional content, interviews, and the opportunity to participate in Q&A using Twitter – in fact, all Q&A for the livestreamed sessions will be using Twitter, so you get to participate just as much as the people in the room.

Thursday and Friday of track 1 on the schedule will be broadcast, including the sessions below. We will also have some more informal chats with the people behind the PyData Seattle conference, and some of the projects represented there.

What should I do right now?

To prepare for the livestream, you can do the following today:

  • Bookmark our livestream page
  • Follow @PyDataSeattle on Twitter
  • Set a reminder for Thursday 6th July at 8:30am to make your beverage of choice, grab some snacks, and settle in for the start of PyData Seattle!

See you next week!

Livestreamed Sessions

See the schedule for updates.

Thursday 6th July

Friday 7th July

The post PyData Seattle is next week! appeared first on Microsoft for Python Developers Blog.

]]>
PyCon US 2017 wrap-up https://devblogs.microsoft.com/python/pycon-us-2017-wrap-up/ Tue, 30 May 2017 22:15:29 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=1485 Last week we took our Python team on the road to PyCon US 2017, which was held in Portland, Oregon, USA. PyCon is our best opportunity for our engineers to meet the broad range of people who make up the Python community. We love the chance to hang out at our booth, meet and chat […]

The post PyCon US 2017 wrap-up appeared first on Microsoft for Python Developers Blog.

]]>
Last week we took our Python team on the road to PyCon US 2017, which was held in Portland, Oregon, USA.

The PyCon US 2017 signs outside the Expo Hall.

PyCon is our best opportunity for our engineers to meet the broad range of people who make up the Python community. We love the chance to hang out at our booth, meet and chat with anyone who comes by, and show off the things we’ve been working on.

The Microsoft booth at PyCon US 2017

Live demos at the Microsoft boot at PyCon US 2017

This year, we had engineers from all over Microsoft representing many different projects. These included Python in SQL Server 2017, Azure Data Lake, Visual Studio 2017, Azure Notebooks, the Azure SDK for Python, Bash for Windows and more. If you missed seeing any of us, feel free to post in the comments below and we’ll provide pointers to more information.

Brett Cannon presenting at PyCon US 2017

(Photo courtesy of Mike Pirnat)

We were also joined by members of our content and evangelism teams, many of whom were attending PyCon for the first time. Microsoft produces a lot of documentation and video content, and our experiences and interactions with the Python community will help ensure that we create the most valuable and accessible content possible.

Several of our engineers presented or moderated sessions, including two talks: “I Installed Python 3.6 on Windows and I Liked It” presented by Steve, and “What’s new in Python 3.6” by Brett. We also chatted with attendees about Windows, Azure, IDEs, packaging, and other topics in the open spaces, as well as contributing to the language summit for CPython core developers.

We would like to thank all the attendees for welcoming us at PyCon this year. Many of us have been attending for five years or more, and it’s one of our favorite conferences. We’re already looking forward to PyCon US 2018 in Cleveland, Ohio!

The Microsoft team attending PyCon US 2017

.

.

.

PyData Seattle 2017

But if you would like to hang out with us sooner than 2018, we will be hosting PyData Seattle this July at our main offices in Redmond, Washington! Tickets are on sale now (all proceeds go to NumFOCUS), keynote speakers are confirmed (and include Joseph Sirosh, VP of Microsoft’s Data group), the schedule is about to be released and there are rumors of live streamed sessions on Channel 9 during the event…

The post PyCon US 2017 wrap-up appeared first on Microsoft for Python Developers Blog.

]]>
Python support is now stable in Visual Studio 2017 https://devblogs.microsoft.com/python/python-now-stable-in-vs-2017/ Wed, 10 May 2017 20:00:15 +0000 http://blogs.msdn.microsoft.com/pythonengineering/?p=1355 Today we have released our next update to Visual Studio 2017, and it’s the one you’ve been waiting for. As of today, the Python development and Data Science and Analytical Applications workloads are stable and ready for production use. You can read our post on the Visual Studio blog for an overview of what is […]

The post Python support is now stable in Visual Studio 2017 appeared first on Microsoft for Python Developers Blog.

]]>
Today we have released our next update to Visual Studio 2017, and it’s the one you’ve been waiting for. As of today, the Python development and Data Science and Analytical Applications workloads are stable and ready for production use.

You can read our post on the Visual Studio blog for an overview of what is new, and we will release a detailed blog in the next few days, but right now, I want to walk through how to install Python support in Visual Studio 2017.

[Edit May 15th] Our blog A Lap around Python in Visual Studio 2017 is now available over on the main Visual Studio blog.

You can use the links below to jump directly to the section that best describes your situation.

 

I have never installed VS 2017 before

Welcome! We’re glad you’re going to try out our tools. If you find anything that doesn’t work as you expect, please use the “Send Feedback” tools within the product to let us know.

For installation, we recommend downloading the installer from the main download page. Then, when prompted to select workloads, choose Python development.

If you already have a copy of Python installed, you can skip installing it again, or select other distros from the right-hand side of the install screen.

Visual Studio installer modify dialog with Python development workload highlighted

 

I have only installed the Preview

Firstly, thanks so much for helping test our early releases. The feedback has been very useful and has made the product better in many ways.

Now that Python is available in the stable release, you have the choice to remove Preview entirely, or to keep using it. Future updates will still be released to Preview first (for example, our next round of bugfixes will be in Preview in just a few weeks), so if you like having early access, you can simply click Update in the installer. Clicking the notification that appears inside Visual Studio will also bring you to this screen.

Visual Studio installer showing Update for Preview

Alternatively, if you want to use the fully supported version of Visual Studio with Python, you can now remove Preview. To do this, rather than click the notification icon in Visual Studio, you will want to launch the installer through Start and select the Uninstall option. You can then install one of the release versions, and make sure to select the Python workload.

Visual Studio installer showing Uninstall selected for Preview

 

I have only installed the stable release

If you’ve been using the release version of Visual Studio, you can now add Python support, but it will include a couple of extra steps.

First, you should update your Visual Studio installation. You’ll see a notification appear within VS that will do this for you.

Next, you will need to open Visual Studio Installer and modify your installation.

Visual Studio installer showing Modify button for release

In the following screen, you will see new options for Python development and Data science and analytical applications. Both of these include Python support, so select either (or both) and any optional components you want from the right-hand side of the installer.

Visual Studio installer modify dialog with Python development workload highlighted

 

I have installed both stable and Preview

Now that Python support is available in the stable release, you have a few options.

If you intend to keep both copies installed, so that you can have the reassurance of using the fully supported version of Visual Studio while also having early access to upcoming updates, simply update both installs.

Visual Studio installer showing the Update button for both releases

Then, for the stable release, click Modify and select the Python development workload to add Python support.

Visual Studio installer showing the Modify button for release while Preview is installed

Visual Studio installer modify dialog with Python development workload highlighted

If you no longer want to keep Preview installed on your machine, you can uninstall it from here, then update and modify the stable install.

Visual Studio installer showing Uninstall selected for Preview

Summary

Thanks again to everyone who helped us out by testing Preview, and we hope you’ll enjoy Python support being available in the main installation. As usual, please send us feedback using Report a Problem in Visual Studio or directly at our GitHub site, and keep an eye on the Visual Studio blog for detailed blogs about our features.

The post Python support is now stable in Visual Studio 2017 appeared first on Microsoft for Python Developers Blog.

]]>