All right, I have a Windows machine. It’s a PITA, but it’s here. And for some reason I started doing some Python testing on it. So this is how I managed to do it:
- Install python with choco (
choco install -y python)
- Run PowerShell as Administrator
Set-ExecutionPolicy -ExecutionPolicy Unrestricted(we’ll see why in a very short time)
Now to code it’s pretty similar to *NIX:
- Create your code folder
- Set up a python venv (
python -m venv .env)
- In VS Code, choose this interpreter
So why the PowerShell stuff? Cause to activate the environment VS Code needs to execute a .ps1 script. Which it can’t, cause “executing scripts is disabled on this machine”, which seems to be the default setting.
All in all, surprisingly straightforward. And I just noticed even the *NIX keyboard shortcuts (CTRL-A, CTRL-K, for example) work in the terminal window now. Crazy.