We’ll create a simple Python Blinky app and connect a LED to your Windows 10 IoT Core device (Raspberry Pi 2 or 3 or MinnowBoard Max). Be aware that the GPIO APIs are only available on Windows IoT Core, so this sample cannot run on your desktop.
While deploying and running a Python UWP app is supported on Windows 10 IoT Core, debugging is currently a known issue for Windows 10 IoT Fall Creators Update (Build 16299) and Visual Studio 2017. We are looking into fixing this in a future release of Windows 10 IoT Core.
Follow the instructions here to setup your device and PC.
Install Python for Windows (3.*) from http://www.python.org/downloads
Download and install PTVS (Python Tools for Visual Studio) VS 2017 latest release from here.
Download and install the latest Python UWP SDK (pyuwpsdk.vsix) release from here.
The setup for this sample is the same as the C# ‘Blinky’ sample.
This application is designed for a headless device. To better understand what Headless mode is and how to configure your device to be headless, follow the instructions here.
You can find the source code for this sample by downloading a zip of all of our samples here and navigating to the
samples-develop\HelloBlinkyBackground\Python. Make a copy of the folder on your disk and open the project from Visual Studio.
If you’re building for MinnowBoard Max, select
x86 in the architecture drop down. If you’re building for Raspberry Pi 2 or 3, select
Make sure you connect the LED to your board. Go back to the basic ‘Blinky’ sample if you need guidance.
Note that the app will not run successfully if it cannot find any available GPIO ports.
The code for this sample is pretty simple. We use _wingpio and time modules.
NOTE: _wingpio reference is already added to the project and is conditioned on the different configuration and platform combinations. For new projects, download pywindevices.zip from CPython UWP SDK releases and add the appropriate reference to your project.
Here is how you set up the blinking led in Python:
Remember that we connected the other end of the LED to the 3.3 Volts power supply, so we need to drive the pin to low to have current flow into the LED.
Follow the instructions to setup remote debugging and deploy the app.
For now, use device name in lieu of IP address. If the device name is not unique, use `setcomputername` tool on the device to reset the device name and reboot.
The Python app will deploy and start on the device.
Launching the debugger for Python can take a few minutes to connect and start debugging the remote Python. If it takes more than a few minutes, there may be a problem with msvsmon on the remote device. Please check the FAQ for any potential fixes/workarounds.
Please refer to the FAQ for issues.