I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace?
-
2As far as I'm aware, vscode doesn't come with built-in support for python. So which extension are you using, and how are you running your program? Also, please see [ask]. – glennsl Sep 23 '17 at 22:00
-
@glennsl well I thought it said it is cross platform and also support Python, and their is a python extension on the program too. – user8662572 Sep 23 '17 at 22:08
-
1Yes, there's quite a few python extensions actually, which is why I asked _which_ one. – glennsl Sep 23 '17 at 22:10
-
I forgot the name but I will check – user8662572 Sep 23 '17 at 22:11
2 Answers
I am not sure how you try to run this program, but you can just go to menu View → Terminal and type python your_program.py
in TERMINAL from the folder where your program is located.
And please check if you have not accidentally installed Visual Studio instead of Visual Studio Code (those are two completely different programs).

- 30,738
- 21
- 105
- 131

- 165
- 6
-
Yeah I have tried that but the terminal said that it can not find the file when I dragged it to the window, and I had also tried to type the name directly but it said it could not find it. – user8662572 Sep 23 '17 at 22:10
-
1You need to navigate to the correct folder with cd and cd .. commands. Or type touch test.py and then code test.py to create new file in your current folder and open it in the editor. – Marko Šarkanj Sep 23 '17 at 22:14
VSCode workspaces are basically just folders. If you open an empty folder in VSCode it will get treated as a workspace, and you can add any scripts you want to it. VSCode will create a new hidden folder in the folder you chose that will hold settings for the workspace. For python, make sure you install the python extension (just grab the one with the most downloads) and follow the instructions there to make sure your python environment is properly configured. If you're using git, you might want to add that hidden folder to the gitignore.

- 320
- 2
- 10