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'Stack Overflow: python 'module' object has no attribute 'compile'
- Someone's badly formatted code with the same problem
- Django tickets {1, 2}
- Again on Ubuntu Forums
- New module causes interesting conflicts
- And here it is again on linuxquestions.org
Fix
Change the filename: call your script se-test.py
or something.