Esoteric Python Filename

I had a strange but minor problem with Python and iPython on my system.  I have a source directory for each of my projects.  Whenever I used the Terminal to launch iPython or Python from that directory I received this error message:

Traceback (most recent call last):

  File “/Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site.py”, line 75, in <module>

    import os

  File “/Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents/lib/python2.7/os.py”, line 49, in <module>

    import posixpath as path

  File “/Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents/lib/python2.7/posixpath.py”, line 17, in <module>

    import warnings

  File “warnings.py”, line 9, in <module>

    from osi import *

  File “osi.py”, line 7, in <module>

    import pandas as pd

ImportError: No module named pandas

This confused me, as I didn’t use a profile or startup script.  I designed a workaround where I launched iPython from another directory and did a cd from within iPython, but this was unsatisfying.  Today I decided to actually look at the error message in detail.  It turns out that I had a local script named “warnings.py” as part of my project which was clobbering the warnings module imported by the os module.  I renamed my local script and that fixed my problem.  I know it’s a bad idea to overload standard module names, I didn’t realize I was doing so.