Raspberry Pi - Upgrading to Python 3.6
Before installing python 3.6 there are some dependencies that need to be installed.
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
Download 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
If errors occur, make sure openssl is installed
$ dpkg -l | grep ssl
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