Eclipse XLRD、XLWT 导入错误
我下载了最新的 Enthought EPD python 发行版(学术版),它附带了 python 2.7。 我使用 Eclipse 作为我的 IDE。
Eclipse 设置为使用此 Python 实例。我在 XLWT 下运行了“images.py”示例文件。
“images.py”:
from xlwt import Workbook
w = Workbook()
ws = w.add_sheet('Image')
ws.insert_bitmap('python.bmp', 0, 0)
w.save('images.xls')
并且 Eclipse 返回:
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
与我尝试在 XLRD、XLUTILS 中运行的任何其他示例类似的问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,确实,“有人”帮助您找到了答案。
它与 xlrd、xlwt、xlutils 或 Eclipse 无关。
一般来说,如果您将一个
import foo
的脚本放入名为foo
的目录中,Python 可能会尝试从该目录导入foo
,并失败。解决方案:不要这样做。将脚本目录重命名为
foo_examples
或foo_scripts
或类似名称。Yes, indeed, "someone" helped you with the answer.
It's nothing to do with
xlrd
,xlwt
,xlutils
, orEclipse
.In general, if you put a script that does
import foo
into a directory namedfoo
, Python is likely to try to importfoo
from that directory, and fail.Solution: Don't do that. Rename your script directory to
foo_examples
orfoo_scripts
or suchlike.