gpt4 book ai didi

python - 在 VS Code 中使用 Python 在代码运行时无法打印到终端

转载 作者:行者123 更新时间:2023-12-01 06:34:57 25 4
gpt4 key购买 nike

我确信这在几天前曾经有效,而且我认为我没有改变任何东西,事实上我只是卸载了 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-return,它会在侧边栏 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

当我运行任何东西时都会打印出来。我不确定以前是否存在,似乎有什么不对劲,但又不确定是什么。

最佳答案

这是由于在 Python 扩展中使用 conda run 导致的问题。这已在最新版本中恢复,因此现在应该可以正常工作了。

关于python - 在 VS Code 中使用 Python 在代码运行时无法打印到终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59718061/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com