assert sys.modules[modname] is old_mod

使用了pypiwin32 包中的pythoncom的时候,当跑在apache下,日志报错:

[Thu Aug 27 17:06:44 2015] [error] [client 127.0.0.1] import pywintypes
[Thu Aug 27 17:06:44 2015] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 124, in <module>
[Thu Aug 27 17:06:44 2015] [error] [client 127.0.0.1] __import_pywin32_system_module__("pywintypes", globals())
[Thu Aug 27 17:06:44 2015] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 114, in __import_pywin32_system_module__
[Thu Aug 27 17:06:44 2015] [error] [client 127.0.0.1] assert sys.modules[modname] is old_mod
[Thu Aug 27 17:06:44 2015] [error] [client 127.0.0.1] AssertionError

解决方案:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Temporary solution is comment out two lines in win32/lib/pywintypes.py:
 
if sys.version_info < (3,0):
 
    #注释掉下面两行就ok了,不要忘记pass!!!!!
 
    #assert sys.modules[modname] is old_mod
 
    #assert mod is old_mod
 
    pass
 
else:
 
    assert sys.modules[modname] is not old_mod
 
    assert sys.modules[modname] is mod
 
    # as above - re-reset to the *old* module object then update globs.
 
    sys.modules[modname] = old_mod
 
    globs.update(mod.__dict__)

  

 

posted @   梦的怒放ing  阅读(1187)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示