python filesystem_error ai_generated partial

OSError: [Errno 28] No space left on device

ID: python/oserror-errno28-no-space

Also available as: JSON · Markdown
80%Fix Rate
85%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
311 active

Root Cause

Disk is full. Common during data processing, logging, or tmp file operations.

generic

Workarounds

  1. 95% success Check disk usage: df -h and du -sh /tmp to find what's full
    df -h and du -sh /tmp to find what's full

    Sources: https://docs.python.org/3/library/shutil.html#shutil.disk_usage

  2. 90% success Clean up temp files, old logs, or __pycache__ directories
    sudo rm -rf /tmp/*
    find /var/log -name '*.gz' -delete
    find . -type d -name __pycache__ -exec rm -rf {} +

    Sources: https://docs.python.org/3/library/tempfile.html

  3. 82% success Set TMPDIR to a volume with more space for temporary files
    export TMPDIR=/mnt/large-volume/tmp
    mkdir -p $TMPDIR
    python my_script.py

    Sources: https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir

Dead Ends

Common approaches that don't work:

  1. Increase disk size as first response 55% fail

    May be a temp dir issue — check where the writes are going

  2. Suppress the error and continue 90% fail

    Data loss is certain if writes are silently failing

Error Chain

Frequently confused with: