Search code examples
pythonvisual-studio-codeterminalautomation

Using Mac OS 12.1 Terminal to open my Visual Studio Code Project


I want to put my command into (I don't know what that would be) terminal that would be able to open my program in visual studio code automatically and run it. I know that this may seem like a pointless thing, but this is exactly what I need. Here is my file path within visual studio code: /Users/Ryanstig/Desktop/Zoon_Automation/import_schedule_test.py ( I have tried running python within terminal doing: "python /Users/Ryanstig/Desktop/Zoon_Automation/import_schedule_test.py" But it does not work at all).


Solution

  • I am afraid you need to open the workspace of the VSCode first. Then you can execute the command in the VSCode's terminal.

    Because, when you want to execute some python file and open the VSCode together, the VSCode will not be able to know which was the workspace folder, and which python interpreter you want to select. So you need to open the workspace folder in the VSCode first. And you can take this command:

    code {the path of workspace folder}
    

    for example:

    code /Users/Ryanstig/Desktop/Zoon_Automation/