Tips for Windows + VS Code users


A couple of things (which I just learned) about Windows and VS Code:

  1. You need to set the correct Python interpreter. To do this, you type Ctrl-Shift-P, then “Python: Select interpreter” and choose “Select interpreter path…”. Then, navigate to the virtual environment you created, drill down into its “Scripts” folder, and then choose python.exe. Helpfully, VS Code will remember this setting whenever it starts back up after being closed.
  2. In order to run a Python file that takes arguments (like the Python practice assignment does), you’ll need to get your Terminal to be “in” the correct folder. To do this, you’ll execute the cd command in the VS Code Terminal, typing something like this:
    cd "C:\Users\joeblow\classes\DATA 419\homeworks"
    

    substituting, of course, the actual path to your actual Python file. Unhelpfully, VS Code will not remember this setting whenever it starts back up after being closed. So you might want to copy that command somewhere safe so you can copy/paste instead of re-discovering and re-typing from scratch each time.

This has been a public service announcement.


Leave a Reply

Your email address will not be published. Required fields are marked *