ModuleNotFoundError: No module named 'xml.etree'; 'xml' is not a package in python

I have a xml (thefile.xml) file.Inside this-

<foo>
   <bar>
      <type foobar="1"/>
      <type foobar="2"/>
   </bar>
</foo>

I have a python file(thefile.py) also-

import xml.etree.ElementTree as ET
root = ET.parse('thefile.xml').getroot()

I am trying to run this in Terminal. Using python3 thefile.py
But i am getting an error it’s like ModuleNotFoundError: No module named ‘xml.etree’; ‘xml’ is not a package

Here is my Error’s screenshot-

Can you please help me to figure out why it’s happening ?

Okay,I should not have any python file named xml.py in my working directory.
This worked for me :smiling_face_with_three_hearts:

1 Like