No usable temporary directory found

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.


Solution 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.

Solution 2:

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

Solution 3:

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

Solution 4:

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")

Solution 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]#