TemporaryDirectory() throws an attribute error when program runs

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.

Full Code:

with tempfile.TemporaryDirectory() as directory:
   for subdir, dirs, files in os.walk(rootdir):
      if subdir != rootdir and subdir != fDestination and subdir != meDir 
      and subdir != fileDestination and subdir != zdir:
         shutil.move(subdir, directory)

verwandte Informationen