Luke Ryan Jernejcic

Python Mac Error: IOError: [Errno 2] No such file or directory …__init__.py

October 22, 2012

This is a situation that I have come upon in Mac OS X Mountain Lion:

IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/__init__.py'

For whatever reason this file is basically missing from the Python install by default. We will not talk about why for Apple has always seemed to install bad versions of Python.

Python needs the __init__.py file to know that it should look inside the folder for code. To fix this error, enter this command:

sudo touch /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/__init__.py

And that should resolve the issue.


Written by Luke Ryan Jernejcic who lives and works in Austin Texas building useful things. Follow him on Twitter