No usable temporary directory found

青春壹個敷衍的年華 提交于 2020-05-24 20:08:21

问题


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

 File "/usr/lib/python2.6/tempfile.py", line 254, in gettempdir
    tempdir = _get_default_tempdir()
  File "/usr/lib/python2.6/tempfile.py", line 201, in _get_default_tempdir
    ("No usable temporary directory found in %s" % dirlist))
IOError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/openerp/openerp-server']

The permission on the directory is 777 owned by root.


回答1:


This kind of error occured in two case

  1. permission(should be drwxrwxrwt and owened by root)
  2. space

To check space(disk usage)just run the command on terminal

df -h

Will list the disk usage on unix and get the output like

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5        28G   15G   12G  58% /

If the root(mounted on /) usage is 100%.

You need to clean the tmp directory or restart the machine or make some space on the root.




回答2:


This error can occur when the file system has been switched to read-only mode.




回答3:


I had the same problem while running a python script in Docker. The following command fixed it for me:

docker rmi $(docker images --quiet --filter "dangling=true")



回答4:


Problem can also occur if inode are full.

You can type df -i

# df -i
Filesystem      Inodes   IUsed  IFree IUse% Mounted on
udev            253841     322 253519    1% /dev
tmpfs           255838     430 255408    1% /run
/dev/xvda1     5120000 5120000      0  100% /
tmpfs           255838       1 255837    1% /dev/shm
tmpfs           255838       7 255831    1% /run/lock
tmpfs           255838      16 255822    1% /sys/fs/cgroup
tmpfs           255838       4 255834    1% /run/user/1000



回答5:


I got the same issue when there was no space on /.

Issue:

File "/usr/lib64/python2.6/tempfile.py", line 201, in _get_default_tempdir("No usable temporary directory found in %s" % dirlist))
IOError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']  [FAILED] 

[root@master hue]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg_master-lv_root

             35G   34G     0 100%     /

tmpfs
7.8G 72K 7.8G 1% /dev/shm

/dev/sda1
477M 34M 418M 8% /boot

When I cleared out some space then it worked fine for me.

[root@master log]# service hue start

Starting hue: [ OK ]

[root@master log]#




回答6:


definately a disk space issue,

on terminal, type df -h you should see output like below ( notice the 100% on one of the filesystems)

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            992M     0  992M   0% /dev
tmpfs           200M   21M  179M  11% /run
/dev/xvda1      7.8G  7.8G  0  100% /
tmpfs          1000M     0 1000M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs          1000M     0 1000M   0% /sys/fs/cgroup
tmpfs           200M     0  200M   0% /run/user/997
tmpfs           200M     0  200M   0% /run/user/1042

in this case, you need to make space by deleting files, artifacts folders e.t.c on path root /




回答7:


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.




回答8:


I ran into this issue earlier today. I started a query embedded in jupyter before going to lunch, and I returned to jupyter throwing some type of error (can't remember what it was exactly). When I tried restarting jupyter in the terminal, I got the error described in OP's question (no usable temporary directory). The answers above didn't work, so I tried restarting my entire VM, at which point I got the error described here. After following the instructions in that thread's top answer, the problem was resolved.



来源:https://stackoverflow.com/questions/16996125/no-usable-temporary-directory-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!