End of support notice: On October 7th, 2026, Amazon will discontinue support for Amazon IoT Greengrass Version 1. After October 7th, 2026, you will no longer be able to access the Amazon IoT Greengrass V1 resources. For more information, please visit Migrate from Amazon IoT Greengrass Version 1.
Install the Amazon IoT Device SDK for Python
Client devices can use the Amazon IoT Device SDK for Python to communicate with Amazon IoT and Amazon IoT Greengrass core devices
(using the Python programming language). For more information, including
requirements, see the Amazon IoT Device SDK for Python Readme
In this step, you install the SDK and get the
basicDiscovery.py sample function used by the simulated
client devices on your computer.
-
To install the SDK on your computer, with all required components, choose your operating system:
- Windows
-
-
Open an elevated command prompt
and run the following command: python --versionIf no version information is returned or if the version number is less than 2.7 for Python 2 or less than 3.3 for Python 3, follow the instructions in Downloading Python
to install Python 2.7+ or Python 3.3+. For more information, see Using Python on Windows . -
Download the Amazon IoT Device SDK for Python
as a zipfile and extract it to an appropriate location on your computer.Make a note of the file path to the extracted
aws-iot-device-sdk-python-masterfolder that contains thesetup.pyfile. In the next step, this file path is indicated bypath-to-SDK-folder. -
From the elevated command prompt, run the following:
cdpath-to-SDK-folderpython setup.py install
-
- macOS
-
-
Open a Terminal window and run the following command:
python --versionIf no version information is returned or if the version number is less than 2.7 for Python 2 or less than 3.3 for Python 3, follow the instructions in Downloading Python
to install Python 2.7+ or Python 3.3+. For more information, see Using Python on a Macintosh . -
In the Terminal window, run the following commands to determine the OpenSSL version:
python>>>import ssl>>>print ssl.OPENSSL_VERSIONMake a note of the OpenSSL version value.
Note
If you're running Python 3, use print(ssl.OPENSSL_VERSION).
To close the Python shell, run the following command:
>>>exit()If the OpenSSL version is 1.0.1 or later, skip to step c. Otherwise, follow these steps:
-
From the Terminal window, run the following command to determine if the computer is using Simple Python Version Management:
which pyenv
If a file path is returned, then choose the Using
pyenvtab. If nothing is returned, choose the Not usingpyenvtab.Using pyenvNot using pyenv- Using pyenv
-
See Python Releases for Mac OS X
(or similar) to determine the latest stable Python version. In the following example, this value is indicated by latest-Python-version. -
From the Terminal window, run the following commands:
pyenv installlatest-Python-versionpyenv globallatest-Python-versionFor example, if the latest version for Python 2 is 2.7.14, then these commands are:
pyenv install 2.7.14 pyenv global 2.7.14 -
Close and then reopen the Terminal window and then run the following commands:
python>>>import ssl>>>print ssl.OPENSSL_VERSIONThe OpenSSL version should be at least 1.0.1. If the version is less than 1.0.1, then the update failed. Check the Python version value used in the pyenv install and pyenv global commands and try again.
-
Run the following command to exit the Python shell:
exit()
-
- Not using pyenv
-
From a Terminal window, run the following command to determine if brew
is installed: which brewIf a file path is not returned, install
brewas follows:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Note
Follow the installation prompts. The download for the Xcode command line tools can take some time.
-
Run the following commands:
brew update brew install openssl brew install python@2The Amazon IoT Device SDK for Python requires OpenSSL version 1.0.1 (or later) compiled with the Python executable. The brew install python command installs a
python2executable that meets this requirement. Thepython2executable is installed in the/usr/local/bindirectory, which should be part of thePATHenvironment variable. To confirm, run the following command:python2 --versionIf
python2version information is provided, skip to the next step. Otherwise, permanently add the/usr/local/binpath to yourPATHenvironment variable by appending the following line to your shell profile:export PATH="/usr/local/bin:$PATH"For example, if you're using
.bash_profileor do not yet have a shell profile, run the following command from a Terminal window:echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profileNext, source
your shell profile and confirm that python2 --versionprovides version information. For example, if you're using.bash_profile, run the following commands:source ~/.bash_profile python2 --versionpython2version information should be returned. -
Append the following line to your shell profile:
alias python="python2"For example, if you're using
.bash_profileor do not yet have a shell profile, run the following command:echo 'alias python="python2"' >> ~/.bash_profile -
Next, source
your shell profile. For example, if you're using .bash_profile, run the following command:source ~/.bash_profileInvoking the python command runs the Python executable that contains the required OpenSSL version (
python2) . -
Run the following commands:
pythonimport sslprint ssl.OPENSSL_VERSIONThe OpenSSL version should be 1.0.1 or later.
-
To exit the Python shell, run the following command:
exit()
-
-
-
Run the following commands to install the Amazon IoT Device SDK for Python:
cd ~ git clone https://github.com/aws/aws-iot-device-sdk-python.git cd aws-iot-device-sdk-python sudo python setup.py install
-
- UNIX-like system
-
-
From a terminal window, run the following command:
python --versionIf no version information is returned or if the version number is less than 2.7 for Python 2 or less than 3.3 for Python 3, follow the instructions in Downloading Python
to install Python 2.7+ or Python 3.3+. For more information, see Using Python on Unix platforms . -
In the terminal, run the following commands to determine the OpenSSL version:
python>>>import ssl>>>print ssl.OPENSSL_VERSIONMake a note of the OpenSSL version value.
Note
If you're running Python 3, use print(ssl.OPENSSL_VERSION).
To close the Python shell, run the following command:
exit()If the OpenSSL version is 1.0.1 or later, skip to the next step. Otherwise, run the command(s) to update OpenSSL for your distribution (for example,
sudo yum update openssl,sudo apt-get update, and so on).Confirm that the OpenSSL version is 1.0.1 or later by running the following commands:
python>>>import ssl>>>print ssl.OPENSSL_VERSION>>>exit() -
Run the following commands to install the Amazon IoT Device SDK for Python:
cd ~ git clone https://github.com/aws/aws-iot-device-sdk-python.git cd aws-iot-device-sdk-python sudo python setup.py install
-
-
After the Amazon IoT Device SDK for Python is installed, navigate to the
samplesfolder and open thegreengrassfolder.For this tutorial, you copy the
basicDiscovery.pysample function, which uses the certificates and keys that you downloaded in Create client devices in an Amazon IoT Greengrass group. -
Copy
basicDiscovery.pyto the folder that contains the HelloWorld_Publisher and HelloWorld_Subscriber device certificates and keys.