Merci de votre visite. Cette page est disponible en anglais uniquement.

Setting Up the ASK SDK

This guide describes how to install the ASK SDK for Python in preparation for developing an Alexa skill.

Prerequisites

The ASK SDK for Python requires Python 2 (>= 2.7) or Python 3 (>= 3.6). Before continuing, make sure you have a supported version of Python installed. To show the version, from a command prompt run the following command:

$ python --version
Python 3.6.5

You can download the latest version of Python here.

Adding the ASK SDK for Python to Your Project

You can download and install the ASK SDK for Python from the Python Package Index (PyPI) using the command line tool pip. If you are using Python 2 version 2.7.9 or later or Python 3 version 3.4 or later, pip should be installed with Python by default.

Many Python developers prefer to work in a virtual environment, which is an isolated Python environment that helps manage project dependencies and package versions. The easiest way to get started is to install the SDK in a virtual environment. See the section Set up the SDK in a virtual environment.

Another option is to install the ASK SDK for Python to a specific folder. This ensures that you have the required dependencies and makes it easy to locate and deploy the required files for your finished skill. See the section Set up the SDK in a specific folder.

Option 1: Set up the SDK in a virtual environment

This option requires you to install the virtualenv package. virtualenv is a tool to create isolated Python environments. To get started, from a command prompt, use the following command to install the package:

$ pip install virtualenv

Next, create a new folder for your Alexa skill and navigate to the folder:

$ mkdir skill
$ cd skill

Next, create a virtual environment called skill_env by issuing the following command:

$ virtualenv skill_env

Next, activate your virtual environment and install the SDK.

Run the following command to activate your virtual environment:

$ source skill_env/bin/activate

The command prompt should now be prefixed with (skill_env), indicating that you are working inside the virtual environment. Use the following command to install the ASK Python SDK:

(skill_env)$ pip install ask-sdk

Depending on the version of Python you are using, the SDK will be installed into the skill_env/lib/Python3.6/site-packages folder. The site-packages folder is populated with directories including:

ask_sdk
ask_sdk_core
ask_sdk_dynamodb
ask_sdk_model
boto3
...

Run the following command to activate your virtual environment:

$ skill_env\Scripts\activate

The command prompt should now be prefixed with (skill_env), indicating that you are working inside the virtual environment. Use the following command to install the ASK Python SDK:

(skill_env)$ pip install ask-sdk

The SDK will be installed into the skill\Lib\site-packages folder. The site-packages folder is populated with directories including:

ask_sdk
ask_sdk_core
ask_sdk_dynamodb
ask_sdk_model
boto3
...

Option 2: Set up the SDK in a specific folder

To get started, from a command prompt create a new folder for your Alexa skill and navigate to the folder:

$ mkdir skill
$ cd skill

Next, install the ASK SDK for Python using pip. The -t option targets a specific folder for installation:

$ pip install ask-sdk -t skill_env

This creates a folder named skill_env inside your skill folder and installs the ASK SDK for Python and its dependencies. Your skill directory should now contain the folder skill_env, which is populated with directories including:

ask_sdk
ask_sdk_core
ask_sdk_dynamodb
ask_sdk_model
boto3
...

Next Steps

Now that you've added the SDK to your project, you're ready to begin developing your skill. Proceed to the next section Developing Your First Skill, for instructions on getting started with a basic skill.