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

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.

intermediate python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated May 21, 2025