User Tools

Site Tools



If I want Python 3.7, I have to compile it myself. Use “dnf” for RedHat based distros and “apt-get” for Debian.

RedHat based distros

sudo dnf install readline-devel  # or up-arrow won't navigate history
sudo dnf install sqlite-devel openssl-devel bzip2-devel
sudo dnf install xz-devel

Then on Fedora and CentOS…

tar -xvf Python-3.7.0.tgz
cd Python-3.7.0/
./configure --prefix=/usr/local/bin/python3.7 --enable-optimizations
sudo make install
# sudo ln -s /usr/local/bin/python3.7/bin/python3 /usr/bin/python3

On my dev system at work, I seem to have configured a prefix like /opt/python3. Then when CentOS updates itself, it changes a symbolic link in /usr/bin/python3

  sudo rm /usr/bin/python3 && sudo ln -s /opt/python3/bin/python3 /usr/bin/python3

For OS X, brew upgrading httpie seems to upgrade to the latest Python 3, so I didn't have to do stuff.

Debian based distros (Start)

For Debian (eg., Rasbian) try the following (on raspberry pi libssl-dev isn't available):

sudo apt-get install build-essential libncursesw5-dev libreadline-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev libffi-dev

(Aside) OpenSSL 1.0.1 issue in Raspbian

On Raspbian Jessie the make command (below) may have output that looks like this:

The necessary bits to build these optional modules were not found:
_bz2                  _lzma                 _ssl

On Raspbian, the pip module may not work because it relies on the ssl module.

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Python's explains:

Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().

If you check the version of ssh:

$ openssl version
OpenSSL 1.0.1t  3 May 2016

That OpenSSL is too old. So you may have to make your own OpenSSL library.

# Add the backport apt source.
echo "deb-src jessie-backports main contrib non-free" | \
      sudo tee /etc/apt/sources.list.d/jessie-backports.list
sudo apt update
# Get the openssl source
apt-get source openssl/jessie-backports
# Make and install it.
cd openssl-1.0.2k/
./config --prefix=/usr
make test
sudo make install

Update: The following apt-cache policy command showed the old libssl was still installed. It's probably bad, but I installed the new one with apt install -t jessie-backports.

sudo apt-cache policy libssl-dev

Debian based distros (Continued)

Then, back to Python3, on Raspbian, I put it in the default location, /usr/local:

screen  # Because using optimizations will take hours
cd Python-3.7.0/
./configure --enable-optimizations
make -j4
sudo make install
[[ $TERM != "screen" ]] || exit  # exit if in screen session


Sometimes I have trouble with pip3 (ImportError: cannot import name 'main' from 'pip'), so prefer to use “python3 -m pip” instead.

sudo -H python3 -m pip install --upgrade pip
sudo -H python3 -m pip install requests
sudo -H python3 -m pip install numpy
sudo -H python3 -m pip install matplotlib
python3 -m pip install --user --upgrade httpie

Weird hack for impyla

Refers to

sudo python3 -m pip install --no-deps impyla
sudo python3 -m pip install --no-deps git+
# sudo python3 -m pip install thriftpy
python3.txt · Last modified: 2021/05/21 00:04 (external edit)