Ensuredispatch Error When Using Cx_freeze For Making Exe
Solution 1:
You are using static proxy which is generated on your disk and which has the compiled executable trouble finding. If you do not know what the static proxy is, you are probably using win32com.client.gencache.EnsureDispatch
which generates static proxy automatically.
The easiest way to fix the problem is to use dynamic proxy by using win32com.client.dynamic.Dispatch
. Static proxy has some benefits, but there is a high possibility that you do not need it.
You can find more information about static and dynamic proxies to COM objects here: http://timgolden.me.uk/python/win32_how_do_i/generate-a-static-com-proxy.html
Solution 2:
I've just figured out that the problem with EnsureDispatch
is within gencache
module, it assumes to be in read-only mode when an executable is built with cx_freeze
.
The following lines allow cache to be built inside AppData\Local\Temp\gen_py\#.#\
directory in Windows 7 x64:
from win32com.client import gencache
if gencache.is_readonly:
gencache.is_readonly = False
gencache.Rebuild() #create gen_py folder if needed
References:
P. S. Performance is much better with static dispatch
Post a Comment for "Ensuredispatch Error When Using Cx_freeze For Making Exe"