XLRD, XLWT, XLUTILS - Eclipse Import Error

716 views
Skip to first unread message

dadashek

unread,
Apr 14, 2011, 12:08:11 PM4/14/11
to python-excel
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
"images.py" example file under XLWT.

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

and Eclipse returned:
Traceback (most recent call last):
File "C:\Documents and Settings\Username\workspace\XLRDXLWT\src\xlwt
\images.py", line 1, in <module>
from xlwt import Workbook
ImportError: cannot import name Workbook

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

Help please!


John Machin

unread,
Apr 14, 2011, 6:37:43 PM4/14/11
to python...@googlegroups.com


On Friday, April 15, 2011 2:08:11 AM UTC+10, dadashek wrote:
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
"images.py" example file under XLWT.

What does "under XLWT" mean?
 

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

and Eclipse returned:
Traceback (most recent call last):
  File "C:\Documents and Settings\Username\workspace\XLRDXLWT\src\xlwt
\images.py", line 1, in <module>
    from xlwt import Workbook

Most probably: Python is trying to find the xlwt package in


C:\Documents and Settings\Username\workspace\XLRDXLWT\src\xlwt

(because that is the script directory, which is given preference to where it was installed (presumably C:\Python27\Lib\site_packages\xlwt)).

Try renaming ...\src\xlwt to e.g. ...\src\xlwt_examples
 

Daniel Adashek

unread,
Apr 15, 2011, 11:56:42 AM4/15/11
to python...@googlegroups.com
Thank you very much John - renaming did it for XLWT and XLRD. XLUTILS still produces the same error, even with the name: "xlutils_example."

Cheers,

On Thu, Apr 14, 2011 at 5:37 PM, John Machin <sjma...@lexicon.net> wrote:


On Friday, April 15, 2011 2:08:11 AM UTC+10, dadashek wrote:
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
"images.py" example file under XLWT.

What does "under XLWT" mean?

Just means I ran the "images.py example file "using/with" XLWT.  
 

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

and Eclipse returned:
Traceback (most recent call last):
  File "C:\Documents and Settings\Username\workspace\XLRDXLWT\src\xlwt
\images.py", line 1, in <module>
    from xlwt import Workbook

Most probably: Python is trying to find the xlwt package in


C:\Documents and Settings\Username\workspace\XLRDXLWT\src\xlwt

(because that is the script directory, which is given preference to where it was installed (presumably C:\Python27\Lib\site_packages\xlwt)).

Try renaming ...\src\xlwt to e.g. ...\src\xlwt_examples
 
ImportError: cannot import name Workbook

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

Help please!


--
You received this message because you are subscribed to the Google Groups "python-excel" group.
To post to this group, send an email to python...@googlegroups.com.
To unsubscribe from this group, send email to python-excel...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/python-excel?hl=en-GB.

John Machin

unread,
Apr 15, 2011, 5:09:08 PM4/15/11
to python...@googlegroups.com

On Saturday, April 16, 2011 1:56:42 AM UTC+10, dadashek wrote:
Thank you very much John - renaming did it for XLWT and XLRD. XLUTILS still produces the same error, even with the name: "xlutils_example."

I doubt very much that the problem is particular to xlutils. What name you use for the directory should be irrelevant, providing it is not the same as the name of any module being imported. If you cannot solve the problem, please show the source of the script you are running, the full path to the script, and the full traceback and error message.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages