Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InProc Server should use full path to pythoncomxx.dll #1704

Closed
Greedquest opened this issue May 15, 2021 · 1 comment
Closed

InProc Server should use full path to pythoncomxx.dll #1704

Greedquest opened this issue May 15, 2021 · 1 comment

Comments

@Greedquest
Copy link

Greedquest commented May 15, 2021

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

@mhammond
Copy link
Owner

I'm actually surprised it wasn't already! Fixed by 3639a92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants