Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5958829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:35:56+00:00 2026-05-22T18:35:56+00:00

i was beggining to follow a tutorial on elementtree in this site http://www.bigfatalien.com/?p=223 so

  • 0

i was beggining to follow a tutorial on elementtree in this site http://www.bigfatalien.com/?p=223 so as usual i typed the reference scripts on the interpreter and i went

import xml.etree.ElementTree as xml

And the interpreter run that command just fine and using “xml” in the intrepreter with no problems my IDE even showed the members of that class on the autocomplete but as soon as i typed the exact same line on a script and tried to run it, it say

object has no attribute ‘etree’

, this line works:

import xml

But if i add:

xml.etree.ElementTree = xml

And try to run that script that doesnt work, i tried with my IDE (pyscripter) and with IDLE, same behaviour.
Whats going on here, whats this behavior, i never read it mentioned on any of the “how to import in python” tutorials or books. I feel i’m missing something obvious.

Update with the error messages requested

Ran the provided lines from IDLE 2.6

2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
[u'C:\\Users\\grillermo\\Desktop', 'C:\\Program Files\\PyScripter\\Lib\\rpyc-python2x.zip', 'C:\\Python26\\lib\\site-packages\\dropbox_client-1.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\simplejson-2.1.6-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\poster-0.8.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\oauth-1.0.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\nose-1.0.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\mechanize-0.2.5-py2.6.egg', 'C:\\Windows\\system32\\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-packages', 'C:\\Python26\\lib\\site-packages\\win32', 'C:\\Python26\\lib\\site-packages\\win32\\lib', 'C:\\Python26\\lib\\site-packages\\Pythonwin', 'C:\\Python26\\lib\\site-packages\\wx-2.8-msw-unicode']
2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
[u'C:\\Users\\grillermo\\Desktop', 'C:\\Program Files\\PyScripter\\Lib\\rpyc-python2x.zip', 'C:\\Python26\\lib\\site-packages\\dropbox_client-1.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\simplejson-2.1.6-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\poster-0.8.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\oauth-1.0.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\nose-1.0.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\mechanize-0.2.5-py2.6.egg', 'C:\\Windows\\system32\\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-packages', 'C:\\Python26\\lib\\site-packages\\win32', 'C:\\Python26\\lib\\site-packages\\win32\\lib', 'C:\\Python26\\lib\\site-packages\\Pythonwin', 'C:\\Python26\\lib\\site-packages\\wx-2.8-msw-unicode']
Traceback (most recent call last):
  File "C:\Users\grillermo\Desktop\xml.py", line 4, in <module>
    import xml.etree.ElementTree as et
  File "C:\Users\grillermo\Desktop\xml.py", line 4, in <module>
    import xml.etree.ElementTree as et
ImportError: No module named etree.ElementTree

The interpreter

C:\>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.ElementTree as et
>>> print et.__file__
C:\Python26\lib\xml\etree\ElementTree.pyc
>>>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:35:57+00:00Added an answer on May 22, 2026 at 6:35 pm

    A really silly question: did you name your script file xml.py? If so, DON’T DO THAT … import xml.anything will be looking in your script file! It’s never a good idea to give a script file the same name as a module that you are going to import.

    Update Tracebacks are your friends. Lead to read them carefully. If you don’t know how to read them, include the traceback in your question.

    I’m betting that yours will look very similar to this:

    Traceback (most recent call last):
      File "xml.py", line 4, in <module>
        import xml.etree.ElementTree as et
      File "C:\junk\xml.py", line 4, in <module> #### here's the culprit ####
        import xml.etree.ElementTree as et
    ImportError: No module named etree.ElementTree
    

    Otherwise:

    Set up a script containing only the following lines:

    import sys
    print sys.version
    print sys.path
    import xml.etree.ElementTree as et
    print et.__file__
    import xml.etree.ElementTree as xml
    print xml.__file__
    

    run it, and show all the output … copy/paste into an edit of your question.

    Repeat the following interpreter session on your computer, and report what is printed:

    C:\junk>\python26\python
    Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import xml.etree.ElementTree as et
    >>> print et.__file__
    C:\python26\lib\xml\etree\ElementTree.pyc
    >>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think i follow instruction from this site very carefully http://source.android.com/source/downloading.html but when i
i follow this manual to lean to use the bashdb: http://archive09.linux.com/articles/153383.html#commentthis And when i
I'm trying to follow this tutorial to try and begin to understand the Visual
This is a follow up question from Problem with array assignment I now have
This is kind of a follow-up question to Perl: add character to begin of
This is a follow-up to Dynamic Shared Library compilation with g++ . I'm trying
This question is a follow up of this question. How can I achieve that
I tried to follow this answer about sending MMS through code. However, I stopped
This is in a way a follow-up of a previously unanswered question of mine
This bug may be lurking since the beginning of ruby-mode , but I noticed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.