'How to run/launch 2+ python scripts at the same in VSC Visual Studio code
Until now I could run 2 or more python scripts at the same time in VSC, but today I reinstalled Anaconda and while I run a 5 minute script, when I try to run a 2nd script, it just prints the path to the 2nd script in the middle of the results from the 1st script:
(base) MacBook-Pro-2:~ sebseb$ /Users/sebseb/opt/anaconda3/bin/python /Applications/MAMP/htdocs/my_folder/my_2nd_script.py
I had no launch.json: so I created one using this code in this post:
https://code.visualstudio.com/docs/editor/debugging#_compound-launch-configurations
I placed it in the same folder as setting.json:
Macintosh HD/Users/sebseb/Library/Application Support/Code/User
I tried to add this to settings.json:
"code-runner.executorMap": {
"go": "cd $dir && go run .",
},
"code-runner.executorMapByGlob": {
"$dir/*.go": "go"
},
I also installed Code Runner from their website:
https://marketplace.visualstudio.com
I was getting Code Language not supported, so I fixed that with this video:
https://www.youtube.com/watch?v=T7tXN9PtO9A
If feels like VSC can't detect Conda, so I run in terminal:
conda update anaconda-navigator
But still I cannot run 2 or more scripts at the same time. What am I doing wrong?
Solution 1:[1]
I think what solved the problem was that I uninstalled the Python Extension, and installed it again, while being in the same Environment. So, 1st select the correct enviroment, then Re-install the Python Extension.
So, click on:
SHIFT + CMD (CTRL Windows) + P
Search for:
Python: Select Interpreter
Then, restarted VScode.
Then, instead of just click on the "Play" icon to run the code, instead I clicked on the arrow next to it. And instead of doing the "Run Code" I did the "Debug Python File" for the 2nd script.
After doing so the 2nd script opened in another tab which the 1st script was running.
I hope this helps someone.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | sebseb |