Kind of a dupe of #1569 (comment) but that is a comment on a closed issue so may not be visible.
Expected behavior and actual behavior.
InProc Server registered from 64 bit python anaconda distribution should work in 64 bit COM client.
Version of Python and pywin32
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
python 3.8.8 hdbf39b2_5
pywin32 227 py38he774522_1
Additional Context
So the registry key for HKCR\CLSID\{clsid}\LocalServer32 is:
C:\Users\...\anaconda3\pythonw.exe "C:\Users\...\anaconda3\lib\site-packages\win32com\server\localserver.py" {clsid}
... whereas for HKCR\CLSID\{clsid}\InprocServer32 it is simply:
pythoncom38.dll
This is a problem for anaconda users who are encouraged not to register their python distribution on the PATH variable, and so need fully qualified paths or to activate their conda env/ use conda run to dynamically add references to the path. The InprocServer32 fails to load in 64-bit office hosts with conda for example.
Workaround
- Easy workaround is use
_reg_clsctx_ = comtypes.CLSCTX_LOCAL_SERVER to avoid creating an inproc server, meaning 64 bit apps default to the working outproc one.
- Better workaround to get the InProc server working, I assume add some things to the PATH and avoid best conda practice - but I'm not sure what. Would you be able to point me in the right direction?
- pythoncom38.dll has many hits on my computer in
C:\WINDOWS\system32, C:\Users\...\anaconda3\Library\bin, C:\Users\...\anaconda3\pkgs\pywin32-227-py38he774522_1\Lib\site-packages\pywin32_system32 etc.
- Best workaround, fully qualify
pythoncom38.dll in the registry as well as any other files it depends on (e.g. python38.dll)
- ...or a combination of fully qualified registry entries and some judicious additions to PATH
See the excellent comments on this SO Question
PS Thank you so much for this library
Kind of a dupe of #1569 (comment) but that is a comment on a closed issue so may not be visible.
Expected behavior and actual behavior.
InProc Server registered from 64 bit python anaconda distribution should work in 64 bit COM client.
Version of Python and pywin32
Additional Context
So the registry key for
HKCR\CLSID\{clsid}\LocalServer32is:... whereas for
HKCR\CLSID\{clsid}\InprocServer32it is simply:This is a problem for anaconda users who are encouraged not to register their python distribution on the PATH variable, and so need fully qualified paths or to activate their conda env/ use
conda runto dynamically add references to the path. TheInprocServer32fails to load in 64-bit office hosts with conda for example.Workaround
_reg_clsctx_ = comtypes.CLSCTX_LOCAL_SERVERto avoid creating an inproc server, meaning 64 bit apps default to the working outproc one.C:\WINDOWS\system32,C:\Users\...\anaconda3\Library\bin,C:\Users\...\anaconda3\pkgs\pywin32-227-py38he774522_1\Lib\site-packages\pywin32_system32etc.pythoncom38.dllin the registry as well as any other files it depends on (e.g.python38.dll)See the excellent comments on this SO Question
PS Thank you so much for this library