Raspberry Pi - Upgrading to Python 3.6

From myWiki
Revision as of 17:19, 22 March 2020 by Stevet (talk | contribs)

Prerequisites Before installing python 3.6 there are some dependencies that we need to install.

sudo apt-get install -y 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 libffi-dev

You can download Python and install python

$ wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
$ tar xzvf Python-3.6.9.tgz
$ cd Python-3.6.9/
$ ./configure && make && sudo make install

It will take a while to complete on a Raspberry Pi 3. If it should happen to fail do:

# make clean

Installing pip

# python3 -m pip install --user --upgrade pip

Check pip version

python3 -m pip --version

Installing virtual environment package

python3 -m pip install --user virtualenv

Create a virtual environment

python3 -m venv env

Activate virtual environment

source env/bin/activate

Deactivate virtual environment

deactivate

Install requests python package

pip3 install requests

Freezing pip dependencies

pip freeze

Using a file to control dependencies create a requirements.txt file containing:

requests==2.18.4
google-auth==1.1.0

And tell pip to install all of the packages in this file using the -r flag:

pip install -r requirements.txt

Upgrading packages with pip3

pip3 install --upgrade requests