No usable temporary directory found

后端 未结 9 1644
迷失自我
迷失自我 2020-12-14 05:51

I am trying to find a temp directory , but when i am trying to get the directory using

tempfile.gettempdir()

it\'s giving me error of

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 06:05

    I had the same issue on the Windows 7x64 machine. It was OK with disk space and permissions.

    When I excecuted

    tempfile.mkdtemp(prefix='MyPrefix_')
    

    manually in python console the directory %TEMP%\MyPrefix_xxxx was successfully created. But when I did the same from script I received the error IOError: [Errno 2] No usable temporary directory found in [...].

    I solved the problem using dir parameter:

     # '.' is a default value for example
     tempfile.mkdtemp(prefix='MyPrefix_', dir=os.environ.get('TEMP', '.')) 
    

    After that from script it worked well.

提交回复
热议问题