First, we'll set up Linux on your Chromebook, then we will install the Python packages and other software we need.
If you can not get your system set up, then repl.it, Python Tutor, and diagrams.net make a reasonable online alternative; however, it feels more real to have things actually running on your own hardware.
If you are on a school Windows laptop, they come with Python already installed. You will need to get a note from me to get VS Code installed by Tony.
Linux is off by default. You can turn it on any time from Settings.
Go to Settings ⚙.
Under "Linux," select Turn On.
Follow the steps on the screen. Setup can take a few minutes.
A terminal window opens giving you a Debian 12 (Bookworm) environment.
Linux on your chrome gives you a terminal (shell, bash) window to access the Linux environment. You can run Linux commands, install more tools using the APT package manager, and customize your shell, etc...
It is a good idea to right-click on the terminal icon ( >_ ) and pin it to the app shelf.
When you open the terminal it will be in your home directory, the shell prompt will be username@penguin:~$ where username is what you chose during setup and penguin is the name of the Linux environment on your Chromebook.
To get ready for the next section we update the package list then upgrade the packages: run this in the terminal: sudo apt update
And then upgrade the currently installed packages : sudo apt upgrade
Here is a good introduction to Linux and the terminal: ryanstutorials.net/linuxtutorial
It will be a good idea to backup your code etc to Google Drive (as well as use version control that we'll discuss later). Open the Files app and make a projects folder in your Software Development folder on Drive.
Then right click that folder and select "Share with Linux".
This folder is now available in the /mnt/chromeos directory. For example, the file shared from the screenshot to the right is at
/mnt/chromeos/GoogleDrive/MyDrive/12SofDev/projects
This isn't very nice, so let's link the entire Google Drive into our home directory in Linux:
ln -s /mnt/chromeos/GoogleDrive/MyDrive/ ~
Note: If you rename the folder in Drive then you will need reshare it to Linux and fix the symbolic link.
You will need to use the Python Package Installer "pip", so open the terminal and type
sudo apt install python3-pip
We can use pip to install lots of useful Python packages, but the one we will definitely need is our GUI environment Flet:
pip install flet flet-cli flet-web flet-desktop --break-system-packages
Note: Depending on the Chromebook you have, you might need to use pip3 instead of pip on the command line.
You might need to add the flet binary to your path - first try restarting the terminal.
If that doesn't work, temporarily fix it: run export PATH="/Directory1:$PATH"
If that wowks, then to do this permanently, you need to edit your Profile: code ~/.profile (but you shouldn't need to)
Note: Managed environment on the Chromebook no longer allows pip installs by default - either say you are happy to potentially break system packages or use virtual environments. The latter is the better choice, we will use the former!
Also using venv in the Google Drive mount has issues...
If you want Flet to be able to run a desktop app on the Chromebooks, you need to install a bunch of GTK libraries - but it's probably not worth the downloads, we'll just use Chrome to render the interfaces. But if you do want, here is the package you need (and its dependencies) sudo apt install libgtk2.0-dev
We'll use the editor/IDE Visual Studio Code which is a light but powerful and popular code editing environment. To install it:
Grab the .deb file from the VS Code downloads page
Open the Files app; Locate the downloaded package
Double click to Install with Linux
To make it work nicely for Python development we need to install some extensions. On the left of the VS Code window, press the extension button (squares) and install:
Python (the extension made by Microsoft)
Draw.io VS Code Integration (does what it says - handy!)
Jupyter (for notebooks like Google Colab - good for explorations)
Optionally install
Ruff autoformatter (had less issues at school than Black!)
TODO Tree useful for tracking TODOs in code
Flet control wrap
GanttDown addon to make Gantt charts (but not quite full featured enough)
TODO Highlight (does what it says)
Device Simulator Express
Python Preview (adds functionality like that at pythontutor.com)
If the extensions don't download, from the terminal run vs code using the command code --ignore-certificate-errors
There are some annoyances to working in the system Python - lots of packages floating around and hard to control.
sudo apt-get install python3-venv
username:~/code/flet$ python3 -m venv .venv
username:~/code/flet$ code .
username:~/code/flet$ source .venv/bin/activate
(.venv) username:~/code/flet$ pip install flet
Note you can see that the shell is in the .venv environment.
In VS code, look at the bottom right and it will say the version of Python and the virtual environment if one is set up.
Todo :)
We can use pip to install other things like an image library and some http/html stuff etc...
pip install pillow requests beautifulsoup4
Get the Data Science libraries ready:
pip install jupyterlab numpy pandas scipy matplotlib altair
You can also install the editor/IDE that comes with the usual Python distribution, IDLE
sudo apt install idle
Previously we used PySimpleGUI - you can grab it if you want:
pip install python3-tk, pysimplegui
How to install VS Code on a Chromebook (windows central)
Coding on a Chromebook Using Python and PyGame (youngwonks.com)
Further Chromebook Hints
Press Ctrl-Alt-/ to see all keyboard shortcuts
Linux Hints
Learn the basics of the terminal - at least navigating the file system using ls & cd
tab completion is your friend; so is the bash history (up arrow)
VS Code Hints
Almost everything is accessible from the Command Pallet: (Ctrl+Shift+P)
Peek Definition (Alt+F12), Run Selected Code in the Terminal (Shift+Enter)
Windows Install
Grab the latest from python.org and code.visualstudio.com
pip install the same packages - might need the --user switch to install only for the current user
Grab the Debian/Ubuntu version from the Downloads page, unzip it and run the .deb file to install the game.
For our class, the only mission you should play is: Mysteries of the Pythonic Temple: "Uncover the secrets of the Python programming language as you explore the ancient Pythonic Temple, the last surviving structure of the fabled City of Python."