Although the introduction to the book says "If you use a Windows computer, you may want to install Windows Subsystem for Linux (WSL)." If fact, WSL is required. I don't think this is necessarily a problem but it should be clarified that the book assumes a POSIX environment and plain Windows isn't going to work.
I tried to get the book's code working in a Windows VM (to mimic the environment my adult son is using) and quickly ran into problems. As pointed out by others, the code uses POSIX directory separators, assumes Python is installed as python3 and uses shebangs and chmod.
Below are my notes for getting Windows configured so the code in this book works correctly. The notes are a bit brief and written from the point of view of a novice Windows user but experienced Linux user. If something doesn't make sense or there is a problem in these instructions please let me know.
Correctly Configuring Windows
-
Install Visual Studio Code:
https://code.visualstudio.com
-
Install the Windows Subsystem for Linux (WSL) Version 2:
https://docs.microsoft.com/en-us/windows/wsl/install-win10
NOTE: This is a rather complicated installation.
-
Install the Ubuntu Linux Distribution (20.04 or Latest LTS)
https://www.microsoft.com/store/apps/9n6svws3rx71
-
Start Ubuntu and install dependencies:
sudo apt update
sudo apt upgrade
sudo apt install python3-pip
-
Get the book's source code, install more dependencies,
and then start Visual Studio Code:
mkdir src
cd src
git clone https://github.com/kyclark/tiny_python_projects.git
cd tiny_python_projects
pip3 install -r requirements.txt
code .
-
Configure Visual Studio Code to use login shells:
In order to use tools like pytest (which are installed in
~/.local/bin) you'll need to configure Visual Studio Code to
start a login shell when opening terminals:
- In Visual Studio: File
-> Preferences -> Settings
- Location: Features
-> Terminal
- Scroll down to: Terminal
-> Integrated -> Shell Args: Linux
- Add the following item:
-l
Although the introduction to the book says "If you use a Windows computer, you may want to install Windows Subsystem for Linux (WSL)." If fact, WSL is required. I don't think this is necessarily a problem but it should be clarified that the book assumes a POSIX environment and plain Windows isn't going to work.
I tried to get the book's code working in a Windows VM (to mimic the environment my adult son is using) and quickly ran into problems. As pointed out by others, the code uses POSIX directory separators, assumes Python is installed as
python3and uses shebangs andchmod.Below are my notes for getting Windows configured so the code in this book works correctly. The notes are a bit brief and written from the point of view of a novice Windows user but experienced Linux user. If something doesn't make sense or there is a problem in these instructions please let me know.
Correctly Configuring Windows
Install Visual Studio Code:
https://code.visualstudio.com
Install the Windows Subsystem for Linux (WSL) Version 2:
https://docs.microsoft.com/en-us/windows/wsl/install-win10
NOTE: This is a rather complicated installation.
Install the Ubuntu Linux Distribution (20.04 or Latest LTS)
https://www.microsoft.com/store/apps/9n6svws3rx71
Start Ubuntu and install dependencies:
Get the book's source code, install more dependencies,
and then start Visual Studio Code:
Configure Visual Studio Code to use login shells:
In order to use tools like
pytest(which are installed in~/.local/bin) you'll need to configure Visual Studio Code tostart a login shell when opening terminals:
->Preferences->Settings->Terminal->Integrated->Shell Args: Linux-l