ERROR: file or directory not found: xx.py

简介: ​1、问题出现原因在vscode中已导入pytest框架,做自动化demo小测试,运行Python文件一直出现如题错误,截图如下:ERROR: file or directory not found: xx.py 2、解决办法1)直接把该文件移到当前主目录下,放在PYTHON-STUDY下2)VSCode中右键tuopan.py文件,选择[在集成终端中打开],或者通过CD命令进入到tuopan.py文件所在目录然后输入以下命令即可:注:上述命令不是换行,在d:/前有空格 ,第一行信息为python所在安装路径,空格后的换行为运行的python文件的所在路径 

1、问题出现原因

在vscode中已导入pytest框架,做自动化demo小测试,运行Python文件一直出现如题错误,截图如下:

ERROR: file or directory not found: xx.pyimage.gif编辑

2、解决办法

1)直接把该文件移到当前主目录下,放在PYTHON-STUDY下


2)VSCode中右键tuopan.py文件,选择[在集成终端中打开],或者通过CD命令进入到tuopan.py文件所在目录

然后输入以下命令即可:

C:/Users/xxx/AppData/Local/Programs/Python/Python310/python.exe d:/WorkSpace/Product/python-study/Demo/xxx/tuopan.py

注:上述命令不是换行,在d:/前有空格 ,第一行信息为python所在安装路径,空格后的换行为运行的python文件的所在路径


命令可以通过直接在报错消息这复制路径即可


无法找到的原因:

目录层次过多过于复杂,无法识别


若本文有帮助到阅读本文的同学,欢迎点赞、关注、收藏,互相学习交流。

相关文章
|
前端开发
【前端异常】Module build failed: Error: ENOENT: no such file or directory, scandir ‘G:\OPWeb\public\node_m
【前端异常】Module build failed: Error: ENOENT: no such file or directory, scandir ‘G:\OPWeb\public\node_m
258 0
|
7月前
|
Shell
adb: error: cannot create file/directory ‘d:/1.png‘: No such file or directory
adb: error: cannot create file/directory ‘d:/1.png‘: No such file or directory
123 0
Error:npm WARN enoent ENOENT: no such file or directory, open ‘C:\Users\XX\package.json‘son‘
Error:npm WARN enoent ENOENT: no such file or directory, open ‘C:\Users\XX\package.json‘son‘
成功解决:ERROR StatusLogger No log4j2 configuration file found.
成功解决:ERROR StatusLogger No log4j2 configuration file found.
ftok info: No such file or directory
ftok info: No such file or directory
227 0
|
JavaScript
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
201 0
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
|
PyTorch 算法框架/工具
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
226 0
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
|
C语言 Python Windows
gcc: error: /FIPython.h: File o directory non esistente
gcc: error: /FIPython.h: File o directory non esistente
119 0
autoreconf: failed to run autopoint: No such file or directory
autoreconf: failed to run autopoint: No such file or directory
220 0