Miniconda VS Code Output Not Running From Code Runner Output Tab

huangapple go评论80阅读模式
英文:

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:

  1. Open command prompt > activate my desired environment.
  2. Open VS Code > Select my desired environment on the Command Palette.
  3. Run Code.

This is what my VS Code terminal shows:
Miniconda VS Code Output Not Running From Code Runner Output Tab

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:

  1. Open command prompt > activate my desired environment.
  2. Open VS Code > Select my desired environment on the Command Palette.
  3. Run Code.

This is what my VS Code terminal shows:
Miniconda VS Code Output Not Running From Code Runner Output Tab

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.

英文:

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.

Miniconda VS Code Output Not Running From Code Runner Output Tab

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, then python 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.

Miniconda VS Code Output Not Running From Code Runner Output Tab

huangapple
  • 本文由 发表于 2023年6月8日 23:56:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76433689.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定