Your file is named `stackexchange.py`, so Python is recursively loading it instead. This is a very common Python pitfall: * [Stack Overflow: *python 'module' object has no attribute 'compile'*](http://stackoverflow.com/q/9149876/1053021) * [Someone's badly formatted code with the same problem](http://python.questionfor.info/q_python_7947.html) * Django tickets {[1](https://code.djangoproject.com/ticket/13872#comment:2), [2](https://groups.google.com/d/msg/django-users/rI7fHSjI7FQ/3KKodbGhdSIJ)} * [Again on Ubuntu Forums](http://ubuntuforums.org/showthread.php?t=947236) * [New module causes interesting conflicts](https://code.google.com/p/jsonpickle/issues/detail?id=4) * [And here it is again on linuxquestions.org](https://www.linuxquestions.org/questions/linux-software-2/python-attributeerror-%27module%27-object-has-no-attribute-%27main%27-4175478873/) # Fix Change the filename: call your script `se-test.py` or something.