英文:
Miniconda VS Code Output Not Running From Code Runner Output Tab
问题
I am an absolute beginner using Python and have been trying to use Miniconda environments. I created a couple of environments and tried to use them with VS Code. Here is my workflow:
- Open command prompt > activate my desired environment.
- Open VS Code > Select my desired environment on the Command Palette.
- Run Code.
This is what my VS Code terminal shows:
My issue is that I have been getting mixed results. Sometimes my code runs on the terminal, but I expected the output to show on Code Runner's Output tab. Sometimes the Output tab shows an error importing packages that are explicitly downloaded on my environment. Am I using the correct workflow with these two tools?
英文:
I am an absolute beginner using Python and have been trying to use Miniconda environments. I created a couple of environments and tried to use them with VS Code. Here is my workflow:
- Open command prompt > activate my desired environment.
- Open VS Code > Select my desired environment on the Command Palette.
- Run Code.
This is what my VS Code terminal shows:
My issue is that I have been getting mixed results. Sometimes my code runs on the terminal, but I expected the output to show on Code Runner's Output tab. Sometimes the Output tab shows an error importing packages that are explicitly downloaded on my environment. Am I using the correct workflow with these two tools?
答案1
得分: 2
It seems you are using both Code Runner and Python extensions. It is not recommended to use the Code Runner extension without special requirements. Please use the official extension Python to execute the code.
Explanation:
-
Code Runner will display the result in the OUTPUT panel by default, and the Python extension will display the result in the integrated terminal.
-
The interpreter you choose for the current workspace (shown in the lower right corner) only applies to the Python extension because that's what it does. The
Select Interpreter
function has no effect on Code Runner. -
If you use Code Runner, it uses the
python -u path\to\name.py
command to execute the script. Then,python
will be the Python interpreter configured by the environment variable path on your machine, not necessarily the one you choose in vscode.
Other information:
If you need Code Runner to output in the terminal, you can add the following settings.
"code-runner.runInTerminal": true,
The name of the terminal tab is code
, which is the green box in the picture. The red box is the terminal executed by the Python extension.
Useful links:
英文:
It seems you are using both Code Runner and Python extensions. It is not recommended to use the Code Runner extension without special requirements. Please use the official extension Python to execute the code.
Explanation:
-
Code Runner will display the result in the OUTPUT panel by default, and the Python extension will display the result in the integrated terminal
-
The interpreter you choose for the current workspace (shown in the lower right corner) only applies to the Python extension, because that's what it does.
Select Interpreter
function has no effect on Code Runner. -
If you use Code Runner, it uses the
python -u path\to\name.py
command to execute the script, thenpython
will be the python interpreter configured by the environment variable path in your machine, not necessarily the one you choose in vscode.
Other information:
If you need Code Runner to output in the terminal, you can add the following settings.
"code-runner.runInTerminal": true,
The name of the terminal tab is code
, which is the green box in the picture. The red box is the terminal executed by the Python extension.
Useful links:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论