PYTHON
Setting up virtual Python environments
Les Pounder enjoys dancing to Jamiroquai’s ‘Virtual Insanity’, but much prefers losing himself in Python’s virtual environments.
OUR EXPERT
Les Pounder is associate editor at Tom’s Hardware and a freelance maker for hire. He blogs about his adventures and projects at http://bigl.es.
YOU NEED
Any Pi An LED 330 ohm resistor (orangeorangebrown-gold)
2x femaleto-male jumper wires Breadboard
Questionary is a fun Python module to create custom user interfaces with the Python shell. Here we use it to blink an LED.
M ost of the time, installing Python modules happens either systemwide, or at a use level. This is fine if your Raspberry Pi is just for one project, but what if your Raspberry Pi is a multi-use machine? Python modules can conflict – modules installed via the OS package manager can be older than those installed using Python’s Pip package manager. In this tutorial, we’re creating a quick and simple virtual environment where we can install Python modules without impacting the underlying operating system.
Open a terminal on your Raspberry Pi and our first goal is to make sure that our Pi is running the latest software. We use Apt to update the list of repositories, and then use that list to upgrade the installed software: $ sudo apt update $ sudo apt upgrade -y