当前位置:网站首页>No such file or directory: ‘/tmp/tmpxxx/tmpxxx.py‘
No such file or directory: ‘/tmp/tmpxxx/tmpxxx.py‘
2022-07-02 15:28:00 【Coding的叶子】
在运行python程序过程中,“No such file or directory” 是个经常容易出现的错误。这个错误比较常见的原因是路径下缺乏相应的文件,或者缺少相应的python库。解决方法主要是在:
(1)在路径下添加缺失的文件或目录。
(2)在程序中通过sys.path.append增加文件或目录所在路径。
(3)通过pip安装缺失的库。
但是,以上所述的情况都不能解决本文所说的错误。我们可以看到,提示的确实文件是在tmp文件夹下,说明该文件是一个临时文件。临时文件一般是python运行是自动产生并清除的。因此,我们是无法找到对应的文件路径,因为这个文件路径是随时可变的。每运行一次,又会在tmp文件夹下产生一个随机名称的文件夹。
详细的错误提示如下所示:
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/tmpn673osmy/tmph_33a_ku.py", line 26, in <module>
lib/python3.7/tempfile.py", line 444, in close
unlink(self.name)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpn673osmy/tmph_33a_ku.py'
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/tmpn673osmy/tmph_33a_ku.py", line 26, in <module>
lib/python3.7/tempfile.py", line 444, in close
unlink(self.name)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpn673osmy/tmph_33a_ku.py'一般造成这个错误的一种可能的原因是相关python文件出现了语法错误。以在mmclassification中文件为例,除了提示该错误之外,在错误信息之前还提到了config.py文件,以及错误NameError: name 'dataset_type' is not defined。因此,问题出现在config.py相关文件,并不一定是config.py自身。
在mmclassification中,config.py是框架自身的文件,不存在语法错误。经检查发现,是自己定义的数据配置文件缺少了datase_type的定义。修复该问题之后,原来的tmp文件缺失错误也得到了修复。
更多三维、二维感知算法和金融量化分析算法请关注“乐乐感知学堂”微信公众号,并将持续进行更新。
边栏推荐
猜你喜欢

Microservice architecture practice: Construction of highly available distributed file system fastdfs architecture

Sword finger offer 22 The penultimate node in the linked list

What if the default browser cannot be set?

The bottom simulation implementation of vector

Eye of depth (III) -- determinant of matrix

Qwebengineview crash and alternatives

Income and risk of linear programming example investment

HBuilderX运行到手机或模拟器提示没有找到设备

From collection to output: inventory those powerful knowledge management tools - inventory of excellent note taking software (4)

【网络是怎样连接的】第六章 请求到达服务器以及响应给客户端(完结)
随机推荐
Dstat use [easy to understand]
Common SQL statements (complete example)
executescalar mysql_ExecuteScalar()
如何给 SAP Spartacus Storefront 创建新的页面
PCL知识点——体素化网格方法对点云进行下采样
Microservice architecture practice: Construction of scalable distributed database cluster
Smart trash can (V) - light up OLED
13、Darknet YOLO3
SAP commerce Cloud Architecture Overview
云通信接口更新迭代——SUBMAIL API V4正式上线
Séparateur JS3 de niuke
Sword finger offer 27 Image of binary tree
MATLAB中nexttile函数使用
HDU - 1114 Piggy-Bank(完全背包)
维护万星开源向量数据库是什么体验
Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition (a sign in, B sign in, C sign in, D thinking +mst
class和getClass()的区别
When the industrial Internet began to enter the deep-water area, it appeared more in the form of industry
Chrome browser quick access stackoverflow