Python Developer Tools from Microsoft. The beginning of the work
For the past few years, Microsoft has been working to add support for the Python developer tools to some of our most popular products: Visual Studio Code and Visual Studio. This year it all worked. In the article we will get acquainted with the tools of the Python developer in Visual Studio, Visual Studio Code, Azure, etc. Look under the cut!
Python is one of the fastest growing programming languages, which is used by both beginners and experienced developers. Its popularity is due to easy to learn semantics and a wide range of applications, from writing scripts to creating Web services and machine learning models.
For more information and the latest news about Python in Microsoft, you can find in the blog Python at Microsoft .
Visual Studio Code
The Python extension for the Visual Studio Code with open source includes other public Python packages to provide developers with ample opportunities for editing, debugging and code testing. Python is the fastest growing language in Visual Studio Code, and the corresponding extension is one of the most popular in the Marketplace section devoted to Visual Studio Code!
To get started with the extension, you need first. download Visual Studio Code, and then, following our manual. Getting started with Python , install the extension and configure the basic functions. Let's consider some of them.
First of all, you need to make sure that Visual Studio Code uses the correct Python interpreter. To change the interpreter, just select the required version of Python in the status bar:
The selector supports many different Python interpreters and environments: Python ? ? virtualenv, Anaconda, Pipenv and pyenv. After selecting the interpreter, the extension will use it for the IntelliSense function, refactoring, analyzing, executing and debugging the code.
To locally run the Python script, you can use the command "Python: Create Terminal" ("Python: create terminal") to create a terminal with the active environment. Press CTRL + Shift + P (or CMD + Shift + P on the Mac) to open the command prompt. To execute a Python file, just right-click on it and select "Run Python File in Terminal":
This command will launch the selected Python interpreter, in this case the Python 3.6 virtual environment, to run the file:
The Python extension also includes debugging templates for many popular application types. Click on the "Debug" tab and select "Add Configuration " in the debug configuration drop-down menu:
You will see ready-made configurations for debugging the current file connecting to a remote debugging server or the corresponding application Flask, Django, Pyramid, PySpark or Scrapy. To start debugging, select the configuration and press the green Play button (or the F5 key on the keyboard, FN + F5 on the Mac).
The Python extension supports various code analyzers for which you can configure the startup after saving the Python file. PyLint is enabled by default, and another analyzer can be selected using the command "Python: Select Linter" ("Python: select code analyzer"):
This is not all: provides support for refactoring, as well as unit testing using unittest, pytest and nose. In addition, you can use Visual Studio Live Share for remote work on the Python code together with other developers!
Python in Visual Studio
Visual Studio supports most of the functions of Visual Studio Code, but it also offers all the useful features of the integrated development environment, which allows you to perform more operations without using the command line. Visual Studio also provides unmatched opportunities for working with hybrid projects Python and C # or C ++.
To include Python support in Visual Studio on Windows, you must select the workload "Development in Python" and (or) the workload "Applications for data processing and analysis and analytical applications" in the Visual Studio installer:
You can install different versions of Python and Anaconda by selecting them in the menu of additional components (see the right part of the screenshot above).
After installing the Python workload, you can get started by creating a Python project in the section using the menu "File -> New Project" (in the list of installed components, select Python):
To create an application from scratch, open the Python application template and start writing the code. You can also create a project by taking as a basis existing Python code or using web templates for Flask, Django and Bottle. Please see our The manual for Flask and The manual for Django to get detailed information on the development of Web applications using these platforms and Visual Studio.
If you have installed a workload for processing and analyzing data, you can also use templates for machine learning projects using Tensorflow and CNTK.
Once the project is created, you can manage the virtual environments and conda environments using the Python Environments node in the Solution Explorer and the Python environment window. By right-clicking on the active Python environment and selecting the corresponding menu item, you can install additional packages:
Visual Studio really demonstrates its capabilities when using Python with other languages. You can combine Python and C ++ projects to create solutions or even embed .py files into C ++ or C # projects!
You can even debug the code in both languages within the same session, for example, by switching from the C ++ debugging type to Python /Native:
For more information on the implementation of Python in C ++ applications, see publication Python insert into the C ++ project. in the Python blog.
In addition, Visual Studio includes Profiler Python and supports modular testing of Python in the Test Explorer.
Python in Azure
Package Azure SDK for Python allows you to create, manage, and interact with Azure services. The Azure CLI command line is written in Python, so almost everything that it allows you to do, you can also execute at the software level using the Python SDK.
You can install separate libraries, for example, to install the SDK to interact with Azure Storage, use the command:
pip install azure-storage
It is recommended to install only the packages you need, but for convenience, you can install the entire Azure SDK package by running the following command:
pip install azure
After installing the SDK, you get access to many useful services, starting from using the machine learning API with Azure Cognitive Services and ending with the allocation of globally distributed data using Azure Cosmos DB .
Web applications can be deployed using the Azure feature "Web application for containers". Check out video From Zero to Azure with Python and Visual Studio Code (in Azure from scratch with Python and Visual Studio Code), providing all the necessary information on the deployment of Flask applications using Visual Studio Code. Also pay attention to short manual To deploy the Flask application using the command line.
In addition, you can run freely placed Jupyter notebooks on Azure, so you do not need a local Jupyter installation. Jupyter notebooks can be accessed for sharing. For example, you can view the shared notebook to create handwritten text using machine learning:
Log in to the account at notebooks.azure.com to try out the cloning and launching of Jupyter notebooks!
Useful materials on the topic
Mini-book "Create better applications and quickly use the data where it is needed"
Read the e-book Create modern applications based on large data on a global scale to learn how a ready-to-use globally distributed database service Azure Cosmos DB changes the approaches to data management. Ensure availability, consistency and data protection using industry-leading enterprise-class technology to meet regulatory and security requirements. Start developing the best applications for your users based on one of five clearly defined patterns of consistency.
Seminar "How to choose the right infrastructure for carrying out your workloads in Azure"
In this seminar, join the story of Microsoft Regional Director Eric Boyd, MVP Azure, on how to choose the right virtual machines, storage and networks for applications and workloads in Azure.
→ Download /Watch
Guide to the architecture of cloud applications
Use a structured approach to developing cloud applications. This 300-page e-book on the architecture of cloud computing discusses architecture, design, and implementation recommendations that apply regardless of the cloud platform chosen. This manual includes steps for:
choosing the right cloud application architecture for your application or solution;
the choice of appropriate technologies for computing and storing data;
implementation of 10 development principles for the creation of a scalable, fault-tolerant and managed application;
follow the five principles of creating high-quality software that guarantees the success of your cloud application;
Use constructive templates designed for the problem that you are trying to solve.
It may be interesting
German Rottweiler Puppy for sale