Visual Studio代码找不到我的python文件。[Errno 2]没有这样的文件或目录

2024-10-01 22:30:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在努力使用Visual Studio代码python编译器。每当我尝试运行代码时,它都会说

python: can't open file 'c:\Users\User\Desktop\Programowasko\Python\Cybepunk encounter 
    calculator\cyberpunk.py': [Errno 2] No such file or directory

到目前为止,在那里编写的唯一代码是print("Hello World")。还有任何其他代码,最近已经工作,现在它没有


Tags: 代码编译器opencalculatorcanusersfilestudio
3条回答

在VS代码中,当我们使用命令“python file.py”在其内部终端中运行python文件时,它要求我们转到可执行文件的父文件夹:(请检查文件名和文件夹名的拼写。)

enter image description here

此外,我们通常在VS代码中使用“python”扩展提供的run按钮,它将在终端中自动执行run命令

错误是由空格引起的。 也许下面的内容可以帮助你

python "c:\Users\User\Desktop\Programowasko\Python\Cybepunk encounter calculator\cyberpunk.py"

您是否尝试过使用没有空格的文件目录?e、 例如Cybepunk_encounter_calculator甚至用双引号括起来""this

相关问题 更多 >

    热门问题