Install Python3 and GPIO to the Raspberry Pi #tt11

Tinkerer: Lory Livezey

In this tutorial, we're going to get the Rasbperry Pi ready for development in Python. In TurboTinker 10, we installed Visual Studio Code. Now, we'll make sure that our Python and GPIO libraries are up to date.

Previous Step

  Configuring Raspberry Pi After Installing Raspbian #tt2

Installing the GPIO Library

First, we'll get the version of our GPIO library...mine is 2.44. Then we'll do a sudo apt-get update to update all of our libraries. Sudo apt-get upgrade could take a very long time if you haven't run it before.

Next, we'll update the GPIO library. Then we'll install a handful of libraries useful for Python programs.

Check the Python version. It's 2.7 when we just type Python.

If we type Python3 to get the Python 3 version, I get version 3.5.3. But as you can see on their web site, the current version is 3.6.5.

We'll start the upgrade by making sure the SSL library is up to date. Then we'll pull Python down using Wget. Run the tar to extract it.

Change to the directory and run ./configure. Then make..

Next, we'll upgrade pip. Pip is a package manager that helps us install libraries.

Then we'll update NumPy. It's a library that helps with multidimensional arrays.

Finally, we're going to check our versions again.

First, the GPIO version, it's been upgraded to 2.46

Next, python 2, by executing python, it's still the same.

And python 3, by executing python3, it's been upgraded to 3.6.5.

Now we're all ready to start programming!

gpio -v

sudo apt-get update sudo apt-get upgrade

sudo apt-get -y install python3-rpi.gpio

sudo apt-get install python-dev python-rpi.gpio

sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev

sudo python --version sudo python3 --version

https://www.python.org/downloads/source/

sudo apt-get install libssl-dev wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz tar xf Python-3.6.5.tar.xz cd Python-3.6.5/ ./configure make sudo make install python3.6 -V sudo python3.6 -m pip install --upgrade pip python3.6 -m pip install --user numpy

sudo apt-get update sudo apt-get upgrade

Be sure to subscribe to our channel!