使用python模块时出现Xlwings错误

时间:2015-08-17 13:34:45

标签: python module pywin32 xlwings

我正在尝试使用Xlwings for Python,但是已经安装了Python 3.5,pywin32扩展和Xlwings,我在开始导入时遇到以下错误:

from xlwings import workbook
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    from xlwings import workbook
  File "C:\Python 3.5\lib\site-packages\xlwings\__init__.py", line 18, in <module>
    from . import _xlwindows as xlplatform
  File "C:\Python 3.5\lib\site-packages\xlwings\_xlwindows.py", line 15, in <module>
    import pywintypes
  File "C:\Python 3.5\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:\Python 3.5\lib\site-packages\win32\lib\pywintypes.py", line 117, in __import_pywin32_system_module__
    assert sys.modules[modname] is not old_mod
AssertionError

2 个答案:

答案 0 :(得分:1)

尝试注释掉断言(用pass替换它们)并查看它是否有效。否则你将需要调试pywintypes。

Felix Zumstein just informed me上述建议无法发挥作用:

  

当您注释掉这些行时,在执行from pywintypes import TimeType: ImportError: cannot import name 'TimeType'

时它会进一步失败

然而,downgrading may solve this problem.

答案 1 :(得分:0)

经过多次试验和错误后,我发现降级到Python 3.3工作

向你致谢所有回复