Skip to content

Instantly share code, notes, and snippets.

@rasmi
Last active January 30, 2025 08:11
Show Gist options
  • Save rasmi/f62799958c0fca26a6f0182100f4468c to your computer and use it in GitHub Desktop.
Save rasmi/f62799958c0fca26a6f0182100f4468c to your computer and use it in GitHub Desktop.
Python development environment setup on Chromebook

Python development environment setup on Chromebook

(also works for a minimal Linux install)

Check for updates

Do this first!

sudo apt-get update && sudo apt-get dist-upgrade

Text Editors

VSCode

Follow the instructions here to download and install the .deb file, or run the following commands:

wget 'https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64' -O code_latest_amd64.deb
sudo apt install ./code_latest_amd64.deb

Other

Optionally, install nano:

sudo apt-get install nano

Python

python3, pip, virtualenv

(already installed on latest ChromeOS Debian releases)

sudo apt-get install python3 python3-dev python3-pip

Add the following lines to your ~/.profile to add ~/.local/bin/ to your PATH:

# Add local bin to PATH
export PATH="$PATH:$HOME/.local/bin"

Then run source ~/.profile to load these environment variables into the current shell.

(optional) install virtualenv

python3 already comes with venv, but if you prefer virtualenv, you can install it:

# Install virtualenv if you don't want to use python's built-in `venv`
pip install --user virtualenv

Create virtual environments

I like to create a global python3 virtual environment to use for ad-hoc development to avoid polluting the system install:

mkdir -p ~/Projects/virtualenvs
cd ~/Projects/virtualenvs

# If using built-in venv:
python3 -m venv pythonenv

# If using virtualenv instead of venv:
virtualenv -p python3 pythonenv

Add the following lines to your ~/.profile to prevent installation of packages outside of a virtual environment. You can use the gpip alias to circumvent this.

export PIP_REQUIRE_VIRTUALENV=true
gpip() {
    PIP_REQUIRE_VIRTUALENV="" pip "$@"
}

Add the following lines to your ~/.profile to easily activate your virtualenvs with aliases.

alias pythonenv="source ~/Projects/virtualenvs/pythonenv/bin/activate"

Then run source ~/.profile.

(optional) Install pydata libraries

pythonenv
pip install numpy pandas ipython jupyter
jupyter notebook .

SSH key setup

Generate a new ssh key:

ssh-keygen -t ed25519 -C "[email protected]"

Manage SSH key passphrase (optional)

If you set a passphrase on your ssh key, install keychain to manage it:

sudo apt-get install keychain

Add the following lines to your ~/.profile to only ask for your ssh key passphrase upon startup.

# Add ssh key to keychain
eval $(keychain -q --eval id_ed25519)

Then run source ~/.profile.

Github ssh key auth

Optionally, add the SSH key to your GitHub account and test it.

# Test ssh auth with GitHub
ssh -T [email protected]
@mishmam
Copy link

mishmam commented Dec 15, 2019

Thank you for putting this together. This was very helpful.

@OvidijusUlis
Copy link

I really appreciate you putting this together. As a beginner at using Linux, it's a bit hard to understand some parts. Like this part "Then run source ~/.profile.".

@rasmi
Copy link
Author

rasmi commented Jan 28, 2020

Thanks for the feedback, @OvidijusUlis. I updated the first time the command is called to clarify what it does!

@btsands
Copy link

btsands commented Feb 28, 2020

I'm curious why you're installing virtualenv (unless you're only talking about Python2). It's already included in Python3. You could just run python3 -m venv venv then $ source ./venv/bin/activate

@rasmi
Copy link
Author

rasmi commented Feb 28, 2020

Hey @btsands, good point! There is no need for it if venv meets your needs. This guide was written in 2018 when having a stack compatible with both Python 2 and 3 was important. It may also be worth switching Pipenv for Poetry.

@btsands
Copy link

btsands commented Feb 28, 2020

Aaah...makes sense; I thought this was more recent (came here from an article on setting up a Chromebook with Python 3.7). Also thanks for the tip on Poetry; will have to check that out!

@ToraMakun
Copy link

Thanks, still relevant to this day. Even though a small update would be welcome especially on the virtual environment part.

@shiang-luong
Copy link

@rasmi
Copy link
Author

rasmi commented Jun 16, 2024

Thanks for the feedback folks! A lot of these steps are no longer necessary for modern Debian/ChromeOS installs, but I've updated this guide in case it is helpful for some.

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