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文件的所在路径


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


无法找到的原因:

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


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

相关文章
|
编解码 C++ Python
成功解决LINK : fatal error LNK1181: 无法打开输入文件“avdevice.lib” error: command 'D:\\Program Files (x86)\\Micr
成功解决LINK : fatal error LNK1181: 无法打开输入文件“avdevice.lib” error: command 'D:\\Program Files (x86)\\Micr
成功解决LINK : fatal error LNK1181: 无法打开输入文件“avdevice.lib” error: command 'D:\\Program Files (x86)\\Micr
|
7月前
|
前端开发
【前端异常】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
69 0
|
5月前
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‘
|
8月前
cancal报错 config dir not found
cancal报错 config dir not found
|
10月前
ftok info: No such file or directory
ftok info: No such file or directory
102 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)
124 0
The file is in the program because: Imported via xxx Root file specified for compilation Vetur(1261)
|
C语言 Python Windows
gcc: error: /FIPython.h: File o directory non esistente
gcc: error: /FIPython.h: File o directory non esistente
90 0
fatal error C1083: 无法打开包括文件:“fenv.h”: No such file or directory
fatal error C1083: 无法打开包括文件:“fenv.h”: No such file or directory
133 0
conftest.c:93:10: fatal error: srtp/srtp.h: No such file or directory
conftest.c:93:10: fatal error: srtp/srtp.h: No such file or directory
91 0
autoreconf: failed to run autopoint: No such file or directory
autoreconf: failed to run autopoint: No such file or directory
135 0