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


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


无法找到的原因:

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


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

相关文章
|
机器学习/深度学习 Linux
解决ImportError libgmpxx.so.4 cannot open shared object file No such file or directory
解决ImportError libgmpxx.so.4 cannot open shared object file No such file or directory
220 0
解决ImportError libgmpxx.so.4 cannot open shared object file No such file or directory
|
6月前
|
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
102 0
|
前端开发
【前端异常】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
194 0
|
11月前
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‘
ftok info: No such file or directory
ftok info: No such file or directory
191 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)
188 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
116 0
|
并行计算 TensorFlow 算法框架/工具
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
290 0
fatal error C1083: 无法打开包括文件:“fenv.h”: No such file or directory
fatal error C1083: 无法打开包括文件:“fenv.h”: No such file or directory
181 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
141 0