Three ways to run Python on Google servers, Your laptop or ACG.maine.edu
Outline
- Install WSL (Windows subsystem for Linux)
- Easiest: Google colab
- Optional: On ACG (Advanced computing group)
Install WSL (Windows subsystem for Linux)
-
Install PowerShell on Windows Installing PowerShell on Windows
- List the Ubuntu versions available to be installed
wsl --set-default-version 2 wsl --list --online
- Install Ubuntu 22.04
wsl --install -d Ubuntu-22.04
- Launch wsl: Press Windows, search wsl
Within WSL
In WSL>Ubuntu-22.04 python comes pre-installed.
-
Launch WSL
-
Type
python3
, press enter -
Enter any python code
print("hello world!")
Press enter.
Within WSL as a file
-
Launch WSL
- Create a text file using notepad or your favorite editer. Enter any python
code within the file.
print("hello world!")
Save the file as first.py
- From the terminal run the python script
first.py
user@machine:~$ python3 first.py
hello world!
Install Jupyter lab
-
Launch WSL
- Install pip
user@machine:~$ sudo apt install python3-pip
- Install Jupyter lab using pip
user@machine:~$ pip3 install --user jupyterlab
- Run Jupyter lab
user@machine:~$ jupyter lab --ip $(hostname -I)
-
Open the URL printer on the screen with the token in a browser of your choice.
-
Click on Notebook > Python 3 > ipykernel
- Enter any python code
print("hello world!")
Press Ctrl+Enter
Easiest: Google colab
- Enter any python code
print("hello world!")
Press Control+Enter to run
- The colab notebooks are saved in your Google drive > Colabs. You can organize them by clicking on File > Move
Optional: On ACG (Advanced computing group)
Please use this method only if your project has outscaled your laptop and colab.research.google.com resources.