IOError
In Python, IOError
is a built-in exception that was used to handle input/output (I/O) related errors, such as problems reading or writing files.
This exception was commonly raised when an I/O operation failed for an I/O-related reason, such as file not found or disk full.
Starting with Python 3.3, IOError
has been merged into the more general OSError
exception, making IOError
effectively an alias for OSError
. You should use OSError
in modern Python code to handle these types of exceptions.
IOError
Occurs When
- Attempting to open a file that does not exist
- Trying to write to a file on a full disk
- Finding problems with file permissions that prevent reading or writing a file
- Having issues with accessing a device or network resource
Related Resources
Tutorial
Python's Built-in Exceptions: A Walkthrough With Examples
In this tutorial, you'll get to know some of the most commonly used built-in exceptions in Python. You'll learn when these exceptions can appear in your code and how to handle them. Finally, you'll learn how to raise some of these exceptions in your code.
For additional information on related topics, take a look at the following resources:
- Python Exceptions: An Introduction (Tutorial)
- Reading and Writing Files in Python (Guide) (Tutorial)
- Python's Built-in Exceptions: A Walkthrough With Examples (Quiz)
- Raising and Handling Python Exceptions (Course)
- Introduction to Python Exceptions (Course)
- Python Exceptions: An Introduction (Quiz)
- Reading and Writing Files in Python (Course)
- Reading and Writing Files in Python (Quiz)
By Leodanis Pozo Ramos • Updated May 21, 2025