Python Forum
Please help me error "AttributeError: 'module' object has no attribute 'ElementTree'"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help me error "AttributeError: 'module' object has no attribute 'ElementTree'"
#1
Hi everyone,
I have trouble when I code python as below.
I have a simple code:
import xlrd
file_location = "D:\Training\Python\Email\aa.xlsx"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(0)
print sheet
After I run the program, it shows error:
Error:
workbook = xlrd.open_workbook(file_location) File "C:\Python27\lib\site-packages\xlrd-1.0.0-py2.7.egg\xlrd\__init__.py", li ne 422, in open_workbook ragged_rows=ragged_rows, File "C:\Python27\lib\site-packages\xlrd-1.0.0-py2.7.egg\xlrd\xlsx.py", line 7 84, in open_workbook_2007_xml ensure_elementtree_imported(verbosity, logfile) File "C:\Python27\lib\site-packages\xlrd-1.0.0-py2.7.egg\xlrd\xlsx.py", line 5 2, in ensure_elementtree_imported Element_has_iter = hasattr(ET.ElementTree, 'iter') AttributeError: 'module' object has no attribute 'ElementTree'
I tried installing xlrd 1.10 (latest version)and xlrd 1.0.0 version. Please help me to fix this problem. Thank all.
Reply
#2
Your file location string looks like it might be a problem. The backslashes will generally try to make the next character into a special character. Try one of the following: double all the backslashes (\\), switch to forward slashes (/), or make it a raw string by putting an r before it (r"D:\Training\...").

Otherwise that code is working for me in 2.7.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(Nov-09-2018, 02:42 PM)ichabod801 Wrote: Your file location string looks like it might be a problem. The backslashes will generally try to make the next character into a special character. Try one of the following: double all the backslashes (\\), switch to forward slashes (/), or make it a raw string by putting an r before it (r"D:\Training\...").

Otherwise that code is working for me in 2.7.

Hi,
I tried but it shows error as
Error:
un(shallow)copyable object of type <type 'element'>
This class is C:\Program Files (x86)\Python\2_7_11\Lib\xml\etree\cElementTree.py
Thanks
Reply
#4
Please post the full error text when posting tracebacks.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
(Nov-11-2018, 03:30 AM)ichabod801 Wrote: Please post the full error text when posting tracebacks.



Thanks for your support. I unchecked break exception. :( and my program is still running normally. I can't understand but I accepted :(
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error: audioio has no attribute 'AudioOut' netwrok 3 655 Oct-22-2023, 05:53 PM
Last Post: netwrok
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 785 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 1,750 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  Need help with 'str' object is not callable error. Fare 4 858 Jul-23-2023, 02:25 PM
Last Post: Fare
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,514 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 763 Jun-22-2023, 02:33 AM
Last Post: woooee
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 3,918 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  Object attribute behavior different in 2 scripts db042190 1 752 Jun-14-2023, 12:37 PM
Last Post: deanhystad
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,396 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  working with TLV module Object Jennifer_Jone 3 1,155 Mar-14-2023, 07:54 PM
Last Post: Jennifer_Jone

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020