Forums

No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', ...

One of my scheduled tasked stopped working, I suppose a while ago, hadn't checked.

File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 500, in _create_tmp_config_dir
  tempfile.gettempdir(), 'matplotlib-%s' % getpass.getuser())
File "/usr/lib/python2.7/tempfile.py", line 265, in gettempdir
  tempdir = _get_default_tempdir()
File "/usr/lib/python2.7/tempfile.py", line 212, 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/noiv']

Probably matplotlib is affected. Should I create one of the mention paths?

Also getting disk quota error on tab completion - after deleting 20MB file...?

Hi noiv,

In regards to your disk quota. You have 20 megs free space. Maybe that's simply not enough for what you are trying to do? That could be causing the problems with your script as well. Especially if it is trying to write somewhere.

The code in tempfile attempts to create a temporary file with a random name in each candidate temporary location in turn, so if your code has already exceeded your quota by the time this line is reached then it could cause that error. If your script's cleanup deletes files that it's created then it might not be immediately obvious that your quota has been exceeded, as when you look later you'll see the space is free again.

The other possibility is that you don't have permission to write to /tmp for some reason. You can check this by running the following in a bash console:

touch /tmp/testfile

If you get an error, then it's a permissions issue and the PA devs would probably need to look into that. If you don't get an error then perhaps it is a quota issue. If there's no error, you may want to tidy up the file you just created:

rm /tmp/testfile

@Cartroo -- great explanation, thanks!

Hansel checked the perms on the various directories when he was looking at it yesterday, and I've just double-checked, and it all looks fine. So your suggestion that the quota might have been exceeded but then something cleared stuff down before @noiv checked it sounds very plausible.

Ah, no need to try those commands I gave above then, @noiv.

As an aside, I think that creating the file is actually quite a clumsy approach. As far as I'm aware, something like this should work on pretty much any platform - I just checked and it appears to work on Windows too:

if os.access(candidate_dir, os.W_OK):
    # ...

That way you'd get things like quota errors when the tempfile is actually created, as you'd expect.