Hi there,

I have Python related issue within TextMate. I am trying to start Python script directly from TextMate, but it fails.

Here comes the output from Terminal:

michalo:/Users/michalo/test> python simple.py 
One
Two
michalo:/Users/michalo/test> cat simple.py 
#!/usr/bin/python

import xml.etree.ElementTree as ET

def main():
element = ET.XML("<root><child>One</child><child>Two</child></root>")
for subelement in element:
print subelement.text

if __name__ == "__main__":
# Someone is launching this directly
main()

michalo:/Users/michalo/test> python simple.py 
One
Two
michalo:/Users/michalo/test> python --version
Python 2.6.1

However, if I use Python bundle to start this script directly from the TextMate (Bundles -> Python -> Run script) I get following error:

ImportError: 'No module named etree.ElementTree'

module body in xml.py at line 3
import xml.etree.ElementTree as ET
copy output
Program exited with code #1 after 0.19 seconds.

If I start it from TextMate Bundles -> Python -> Run script (Terminal)), I am getting following error:

Traceback (most recent call last):
  File "/Users/michalo/Documents/work_files/public/notes/python/xml.py", line 3, in <module>
    import xml.etree.ElementTree as ET
  File "/Users/michalo/Documents/work_files/public/notes/python/xml.py", line 3, in <module>
    import xml.etree.ElementTree as ET
ImportError: No module named etree.ElementTree
michalo:/Users/michalo/Documents/work_files/public/notes/python> 

Do you know what can be the source of the issue?

That's what I get from the Terminal windows (when I try to get Python version):

michalo:/Users/michalo/test> which python
/usr/bin/python
michalo:/Users/michalo/test> python --version
Python 2.6.1
michalo:/Users/michalo/test>

And you can find attached screen shoot from text mate. I have created simple text file:

which python
python --version

And executed it with: Bundles -> Shell Scripts -> Run script

Does anyone have an idea what's wrong here?

Cheers

Michal