在代码运行时在vs代码中使用Python无法打印到终端

时间:2020-01-13 13:55:58

标签: python visual-studio-code

我确信这在几天前就可以使用,并且我认为我没有做任何更改,实际上我只是卸载了anaconda和vscode,然后重新安装了所有程序以查看是否有效,但没有帮助。

但是终端只会在代码运行时才在末尾打印

例如,如果我运行此

import time

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

什么都没发生。

如果我运行此

import time

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

在1.5秒内什么都没打印,然后一气呵成

如果我突出显示代码并按shift键返回,则它会在侧栏Jupyter Server中正常运行。我迷路了

无论如何,感谢您的帮助!

好的,抱歉,我刚刚发现了其他东西

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

当我执行任何操作时,此打印输出。我不确定它是否曾经存在过,似乎有些不正确,但不确定是什么。

1 个答案:

答案 0 :(得分:1)

这是一个问题,原因是在Python扩展中使用了conda run。在最新的发行版中已对此进行了还原,因此现在应该可以使用了。