首页 > 解决方案 > TemporaryDirectory() throws an attribute error when program runs

问题描述

I am attempting to create a temporary directory using with tempfile.TemporaryDirectory() as directory:

I have imported tempfile

When I run the program I get the error:

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

I am running python 3.8

The program will run successfully if run with the debugger but when I run it without the debugger I get this error.

标签: pythontemporary-files

解决方案


推荐阅读