Skip to content

Instantly share code, notes, and snippets.

@swipswaps
Forked from uogbuji/debian-pydev.md
Created May 8, 2021 17:09
Show Gist options
  • Save swipswaps/9d9596a6753336215c01567df5f1bc57 to your computer and use it in GitHub Desktop.
Save swipswaps/9d9596a6753336215c01567df5f1bc57 to your computer and use it in GitHub Desktop.
My Python dev setup for Linux (Debian, Ubuntu, Mint & ChromeOS/Crostini)

User local install as much as possible, leaving system-wide kit (e.g. python & python-pip .debs) alone. Tested on Debian, Ubuntu, Mint & ChromeOS/Crostini.

Environment

Set up the dev environment (this is the only system-wide part):

sudo apt install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev
#Optionally:
sudo apt install libxml2-dev libxslt1-dev git mercurial

Install Python

mkdir -p $HOME/.local/venv
mkdir -p ~/src
# mkdir -p ~/Downloads # If needed
cd ~/Downloads
wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz
cd ~/src
tar xvf ~/Downloads/Python-3.8*
cd Python-3.8.3
./configure --enable-optimizations --prefix=$HOME/.local
make; make install

Create & activate a virtual envirnment

Create:

export DEVENVTAG=main
$HOME/.local/bin/python3 -m venv $HOME/.local/venv/$DEVENVTAG

You only need to specify the full path to Python when creating the venv, as above.

Activate:

source $HOME/.local/venv/$DEVENVTAG/bin/activate
pip install wheel #Recommended; One time per venv
pip install --upgrade pip #Needed from time to time, to make sure pip itself is up to date

In future you only need the first line above to activate the venv.

Appendix: What's the system Python on Debian, anyway?

First of all you can check whether the Debian version you want has the Python version you want. In August 2020 a query:

https://packages.debian.org/search?keywords=python+3.8

Indicated that the 3.8 version was only in testing and unstable, not in stable (when installed you got 3.8.5).

Stable had Python 3.7 (3.7.3)

https://packages.debian.org/search?keywords=python+3.7

You can install Python 3 and other dev environment bits system-wide

sudo apt install python3 python3-dev python3-venv

Though I still recommend sticking to .local and not mucking with system-level Python versions at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment