python 3.7.3 install on debian jessie

Things like conda make setting up complex python projects simpler, but create a whole parallel world. Sometime you want to just fix the current OS, and at most use virtualenvs (I dislike introducing too many layers). I have a debian jessie (8.1) VM (oldstable), and I wanted to have modern python 3 on it, so I decided to install the latest python (3.7.3).

  1. Install dependencies
      sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

    It turns out that the shipped openssl is too old to build the ssl module, so it is better to get the latest stable openssl and install it (I did it in my home):

    tar xzf openssl-1.1.1c.tar.gz
    cd openssl-1.1.1c
    ./config --prefix=$HOME
    make test
    make install
  2. Getting the python source:
    tar xzf Python-3.7.3.tgz
      cd Python-3.7.3
  3. building and installing it:
    make clean
    ./configure --prefix=$HOME --with-openssl=/home/fawzi LDFLAGS="-Wl,-rpath=/home/fawzi/lib -L/home/fawzi/lib"
    make install

    The LDFLAGS there are really needed (otherwise the ssl module is built, but it cannot be tested and is not installed), and simply setting it in the environment is not enough, you really need to pass them like that…

  4. pip
    Somehow the build process is too smart, and seeing it is on debian it somehow thinks it is a system install, and disables pip, and names python python3, so we fix that:
    ln -s ~/bin/python3 ~/bin/python
    curl -o
    pip install --upgrade pip
  5. virtualenv
    Finally we install also virtualenv
    pip install virtualenv

Leave a comment

Comments are moderated. Your email address is neither published nor stored, only an md5 hash of it. Required fields are marked with *