3

Sorry if this is a stupid question, but I have not been able to solve it through the following related threads:

Visual studio code is not showing the ouput of python

How to execute Python code from within Visual Studio Code

I just installed VS Code for Windows v. 1.41 and I'm using Python 3.7.4 through an Anaconda distribution. After I upgraded VS Code, it will no longer print statements during a code run, only in the end will it print everything at once.

I tried to open "Task: Configure Default build task" and opening tasks.json, which has the following content:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "python",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            },
            "args": [
                "${file}"
            ],
            "group": {
                "kind": "test",
                "isDefault": true
            }
        }
    ]
}

As far as I understood, it should be either "echo" or "reveal" that should be responsible for the missing print statements during code execution, but both are set to true..

Does anyone have a solution for this? I would prefer to not use the Code Runner extension, if possible.

Malte Jensen
  • 187
  • 1
  • 11

1 Answers1

4

I've also been having this issue since my extension version was forcefully updated to version 2020.1.57204, which changed the "Run Python in Terminal" command as follows:

Use "conda run" (instead of using the "python.pythonPath" setting directly) when executing Python and an Anaconda environment is selected.

The command "conda run" is still somewhat experimental, and really shouldn't have been implemented in VSCode so soon. I'm on a mac, but the observed behavior is the same as yours, and when I use "conda run" in an external terminal, the stdout is still swallowed and then dumped all at once, so I put this down to an issue with conda, rather than an issue with VSCode (overeager implementation changes aside).

However, if "conda run" isn't being called when you run code, then unfortunately I don't know what's gone wrong in your case.

Joshua
  • 56
  • 1
  • 2
    BTW, you can try [rolling back](https://code.visualstudio.com/updates/v1_30#_install-previous-versions) the version of the python extension which worked for me – Joshua Jan 08 '20 at 16:32
  • So `conda run` has been out for a year, so it's been experimental for a while. ;) We also switched to using it in the extension to fix other issues we have to work around due to conda's design. Basically we had to choose between the lesser of two evils. – Brett Cannon Jan 08 '20 at 23:33
  • Hi Joshua, thank you for your comment! Did you manage to solve this in any other way than rolling back the the python extension, or is it the only solution as of now? – Malte Jensen Jan 09 '20 at 19:27
  • 1
    Rolling back is the only solution for now, but we are working on the overall issue now and plan to address in a point release (aiming for Monday). – Brett Cannon Jan 09 '20 at 20:03