Install Python3.6 on Jetson TK1 From Source

Jetson TK1 come with Python 3.4 by default. But this version too old even for installing newer pip. Before deciding to install from source, I’m trying several option like installing Python 3.6 through apt or using ubuntu PPA ppa:deadsnakes/ppa, but always failing to install pip from and I end up to using Python 3.6 by installing them from source.

  • OS : Ubuntu 14.04
  • Architecture : Armv7 (ARM 32bit)
  • Ensure to remove Python 3.6 if installed through apt or via PPA,
sudo apt-get autoremove python3.6
  • Install prerequisite library ,
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install build-essential
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev
  • Download Python 3.6 source,
tar xvf Python-3.6.1.tar.xz
cd Python-3.6.1
  • Configure and Install Python 3.6,
sudo ./configure --enable-shared
sudo make altinstall
  • Add python3.6’s lib path to the $LD_LIBRARY_PATH environment variable on .bashrc ,
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' >> ~/.bashrc
  • reload .bashrc ,
source .bashrc
  • After finish installing you need to logout and login back to Jetson TK1, then verify installation by checking installed pip version,
pip3.6 -V
  • Output should be,
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
  • Python Dev contain header files that can be used for building Python extension, to check our installation successfully included a Python Dev into it, use script below,
from distutils.sysconfig import get_makefile_filename as m
from os.path import isfile
import sys
sys.exit(not isfile(m()))
  • Save as ,
  • Then run this command in terminal,
python3.6 && echo "Ok" || echo "Error: Python header files NOT found"
  • The output should be "ok” .
  • After Python 3.6 installation success, now we can create Virtual Environment,
mkdir -p ~/Python3.6/env
python3.6 -m venv ~/Python3.6/env
  • Activate Environment,
source ~/Python3.6/env/bin/activate
  • After that, your environment will be active in current terminal session,
(env) ubuntu@tegra-ubuntu:~/
  • Install Numpy ,
python3.6 -m pip install Cython
python3.6 -m pip install numpy
  • Install Matplotlib ,
python3.6 -m pip install certifi
python3.6 -m pip install cppy
python3.6 -m pip install matplotlib
  • Test library,
import numpy as np
import matplotlib.pytplot as plt
import matplotlib
x = np.random.randint(low=0, high=15, size=10)
y = np.random.randint(low=0, high=15, size=10)
plt.plot(x, y)
  • Result should be something like this,
matplotlib plot from numpy random array

At this point we are successfully installed Python and necessary library in Jetson TK1.

IoT Engineer, Software Developer & Machine Learning Enthusiast