Resources
https://code.visualstudio.com/docs/python/python-tutorial
Creating a new Python project
VS Code menu > File > Open Folder
Open a folder that will be your workspace (you can just open an empty folder you’ve created).
Turn off Dropbox if your folder is within Dropbox (causes file access issues for us at times)
Now create a virtual environment for this project (recommended approach when using Python, so individual projects and their dependencies are kept isolated from each other).
Open the Command Palette (Ctrl+Shift+P) and enter “Python: Create Environment”
Select “Venv” (default, or whatever you want to use)
Select the interpreter to use (the version of Python you’ve installed on your machine).
Wait for the progress to complete. Check for any errors.
Create a new file
Menu > File > New file… > MyFileName.py
Running the Project
Use the play button at the top right of the code editor window “Run Python File”.
Debugging the project
Press F5
Or use the dropdown option on the play button at the top right of the code editor window and select “Debug Python File”.
Then use menu > Run options to control debugging.
There is also the left “Run and Debug” panel which shows various debug info.
Install python packages you want to use in your code
Open the Command Palette (Ctrl+Shift+P) and enter “Terminal: Create New Terminal” to create a powershell terminal window.
Say you want to install the “requests” python package:
py -m pip install requests
Troubleshooting
If there are errors creating the virtual environment
Right click the Output window and select “Clear output” before trying again, so you are not looking at old errors.
If you make changes to try and fix, you can delete the .venv directory and try again (seems to work better than telling VS code to do it when running “Python: Create Environment” again in our experience).