user3497301
user3497301

Reputation: 13

using Python in vs code cannot print to terminal while the code is running

I am sure this used to work a few days ago and I don't think I have changed anything, in fact I just uninstalled anaconda and vscode and reinstalled it all to see if that worked but did not help.

But the terminal only prints at the end never as the code runs

eg if I run this

import time

while True:
    time.sleep(.5)
    print('true')

nothing happens.

If I run this

import time

time.sleep(.5)
print('true')
time.sleep(.5)
print('true')
time.sleep(.5)
print('true')

Nothing is printed for 1.5 seconds then it all comes at one go

if I highlight the code and shift-return it runs as expected in the side bar Jupyter Server thing. I am lost

anyway thanks for any help you can give!

OK sorry I just noticed something else

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.   
Try the new cross-platform PowerShell https://aka.ms/pscore6

. : File C:\Users\Jasper\Documents\WindowsPowerShell\profile.ps1 cannot b
information, see about_Execution_Policies at https:/go.microsoft.com/fwli
At line:1 char:3
+ . 'C:\Users\Jasper\Documents\WindowsPowerShell\profile.ps1'
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
+ conda activate base
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (conda:String) [], CommandNotFoundExceptioneption
    + FullyQualifiedErrorId : CommandNotFoundException

this is printed out when I run anything. I am not sure if it was there before, it seems like something is not correct, but not sure what.

Upvotes: 1

Views: 253

Answers (1)

Brett Cannon
Brett Cannon

Reputation: 15990

This was an issue due to the use of conda run in the Python extension. This has been reverted in the latest point release so things should work now.

Upvotes: 1

Related Questions