Captain Cretaceous Captain Cretaceous - 10 months ago 48
Python Question

Eclipse XLRD, XLWT Import Error

I downloaded the latest Enthought EPD python distribution (academic), which comes with python 2.7.
I am using Eclipse as my IDE.

Eclipse is set up to use this instance of Python. I ran the "" example file under XLWT.


from xlwt import Workbook
w = Workbook()
ws = w.add_sheet('Image')
ws.insert_bitmap('python.bmp', 0, 0)'images.xls')

and Eclipse returned:

Traceback (most recent call last):
File "C:\Documents and Settings\Username\workspace\XLRDXLWT\src\xlwt\", line 1, in
from xlwt import Workbook
ImportError: cannot import name Workbook

Similar problem with any other example I try to run in XLRD, XLUTILS.


Yes, indeed, "someone" helped you with the answer.

It's nothing to do with xlrd, xlwt, xlutils, or Eclipse.

In general, if you put a script that does import foo into a directory named foo, Python is likely to try to import foo from that directory, and fail.

Solution: Don't do that. Rename your script directory to foo_examples or foo_scripts or suchlike.