プログラムの実行時にTemporaryDirectory()が属性エラーをスローする

プログラムの実行時にTemporaryDirectory()が属性エラーをスローする

私は一時ディレクトリを作成しようとしています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を実行しています

デバッガーを使用して実行するとプログラムは正常に実行されますが、デバッガーを使用せずに実行するとこのエラーが発生します。

完全なコード:

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)

関連情報