Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
163 lines (124 sloc) 9.87 KB
title description services documentationcenter author manager editor ms.assetid ms.service ms.workload ms.tgt_pltfrm ms.devlang ms.topic ms.date ms.author
Install Python and the SDK - Azure
Learn how to install Python and the SDK to use with Azure.
python
lmazuel
wpickett
f36294be-daeb-4caf-9129-fce18130f552
multiple
na
na
python
article
09/06/2016
lmazuel

Installing Python and the SDK

Python is easy to setup on Windows and comes pre-installed on Mac, Linux, and Bash for Windows. This guide walks you through installation and getting your machine ready for use with Azure.

What's in the Python Azure SDK?

The Azure SDK for Python includes components that allow you to develop, deploy, and manage Python applications for Azure. Specifically, the Azure SDK for Python includes the following:

  • Management libraries. These class libraries provide an interface managing Azure resources, such as storage accounts, virtual machines.
  • Runtime libraries. These class libraries provide an interface for accessing Azure features, such as storage and service bus.

Which Python and which version to use

There are several flavors of Python interpreters available - examples include:

  • CPython - the standard and most commonly used Python interpreter
  • PyPy - fast, compliant alternative implementation to CPython
  • IronPython - Python interpreter that runs on .Net/CLR
  • Jython - Python interpreter that runs on the Java Virtual Machine

CPython v2.7 or v3.3+ and PyPy 5.4.0 are tested and supported for the Python Azure SDK.

Where to get Python?

There are several ways to get CPython:

Unless you have a specific need, we recommend the first two options.

SDK Installation on Windows, Linux, and MacOS (client libraries only)

If you already have Python installed, you can use pip to install a bundle of all the client libraries in your existing Python 2.7 or Python 3.3+ environment. This will download the packages from the Python Package Index (PyPI).

You may need administrator rights:

  • Linux and MacOS, use the sudo command: sudo pip install azure-mgmt-compute.
  • Windows: open your PowerShell/Command prompt as an administrator

You can install individually each library for each Azure service:

   $ pip install azure-batch          # Install the latest Batch runtime library
   $ pip install azure-mgmt-scheduler # Install the latest Storage management library

Preview packages can be installed using the --pre flag:

   $ pip install --pre azure-mgmt-compute # will install only the latest Compute Management library

You can also install a set of Azure libraries in a single line using the azure meta-package. Since not all packages in this meta-package are published as stable yet, the azure meta-package is still in preview. However, the core packages, from code quality/completeness perspectives can be considered "stable" at this time

  • it will be officially labeled as such in sync with other languages as soon as possible. We are not planning on any further major changes until then.

Since it's a preview release, you need to use the --pre flag:

   $ pip install --pre azure

or directly

   $ pip install azure==2.0.0rc6

Getting More Packages

The Python Package Index (PyPI) has a rich selection of Python libraries. If you chose to install a Distro, you'll already have most of the interesting bits for various scenarios from web development to Technical Computing.

Python Tools for Visual Studio

Python Tools for Visual Studio (PTVS) is a free/OSS plugin from Microsoft, which turns VS into a full-fledged Python IDE:

how-to-install-python-ptvs

Using PTVS is optional, but is recommended as it gives you Python and Web Project/Solution support, debugging, profiling, interactive window, Template editing, and Intellisense.

PTVS also makes it easy to deploy to Microsoft Azure, with support for deployment to Cloud Services and Websites.

PTVS works with your existing Visual Studio 2013, 2015, or 2017 installation. For documentation, downloads and discussions, see Python Tools for Visual Studio.

Python Azure Scenarios for Linux and MacOS

For Linux or MacOS, main Azure scenarios that are supported:

  1. Consuming Azure Services by using the client libraries for Python
  2. Running your app in a Linux VM
  3. Developing and publishing to Azure Websites using Git

The first scenario enables you to author rich web apps that take advantage of the Azure PaaS capabilities such as blob storage, queue storage, table storage etc. via Pythonic wrappers for the Azure REST APIs. These works identically on Windows, Mac, and Linux. You can also use these client libraries from your local development machine or a Linux VM running on Azure.

For the VM scenario, you simply start a Linux VM of your choice (Ubuntu, CentOS, Suse) and run/manage what you like. As an example, you can run IPython REPL/notebook on your Windows/Mac/Linux machine and point your browser to a Linux or Windows multi-proc VM running the IPython Engine on Azure. See the IPython Notebook on Azure tutorial for more information.

For information on how to setup a Linux VM, please see the Create a Virtual Machine Running Linux tutorial.

Using Git deployment, you can develop a Python web application and publish it to an Azure Website from any operating system. When you push your repository to Azure, it will automatically create a virtual environment and pip install your required packages.

For more information on developing and publishing Azure Websites, see the tutorials for Creating Websites with Django, Creating Websites with Bottle, and Creating Websites with Flask. For more general information on using any WSGI-compliant framework, see Configuring Python with Azure Websites.

Additional Software and Resources: