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__) |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步