程序运行时,TemporaryDirectory()引发属性错误

2024-05-23 20:49:34 发布

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

我正在尝试使用with tempfile.TemporaryDirectory() as directory:创建一个临时目录

我已导入临时文件

当我运行程序时,我得到错误:

Traceback (most recent call last):
  File "batch.py", line 79, in <module>
    with tempfile.TemporaryDirectory() as directory:
AttributeError: 'module' object has no attribute 'TemporaryDirectory'

我正在运行python 3.8

如果使用调试器运行,程序将成功运行,但如果在不使用调试器的情况下运行,则会出现此错误


Tags: 程序目录mostas错误withcalltempfile