Xpra: Ticket #2573: No module named 'comtypes.gen.stdole'

Resurrecting #1899:

"Xpra-Python3-x86_64_4.0-r24952\xpra_cmd" shadow ssh://user@ip/0  --opengl=no --desktop-scaling=0.75 --min-speed=70 --webcam=no --speaker=off --microphone=off --pulseaudio=no --exit-with-client=no
2020-02-03 14:07:25,294 Xpra GTK3 client version 4.0-r24952 64-bit
2020-02-03 14:07:25,294  running on Microsoft Windows 10
2020-02-03 14:07:26,075 GStreamer version 1.16.2 for Python 3.8.0 64-bit
2020-02-03 14:07:26,653 Connected (version 2.0, client OpenSSH_7.2p2)
2020-02-03 14:07:26,731 SSH password authentication failed:
2020-02-03 14:07:26,731  Bad authentication type; allowed types: ['publickey', 'password']
please enter the SSH password for user@ip:
2020-02-03 14:07:41,465 Authentication (password) failed.
2020-02-03 14:07:41,465 SSH password authentication failed:
2020-02-03 14:07:41,465  Authentication failed.
please enter the SSH password for user@ip:
2020-02-03 14:07:54,011 Authentication (password) successful!
2020-02-03 14:07:55,699 Error: failed to query network interface:
2020-02-03 14:07:55,699  No module named 'comtypes.gen.stdole'
2020-02-03 14:07:55,730  keyboard settings: layout=us


Mon, 03 Feb 2020 12:36:38 GMT - stdedos:

2020-02-03 14:35:45,128 Error: failed to query network interface:
2020-02-03 14:35:45,128  module 'comtypes.gen.WbemScripting' has no attribute 'ISWbemLocator'

etc ...


Mon, 03 Feb 2020 14:23:29 GMT - Antoine Martin: owner changed

Originally the bug only occurred with 32-bit builds: ticket:1899#comment:2. But python-comtypes is so flaky that it looks like it's broken again, even on 64-bit now?

Can you set:

set XPRA_SILENCE_COMTYPES=0

Then run xpra with:

Xpra_cmd -d util ...

This should give a lot more details about what / where things are failing.


Fri, 07 Feb 2020 09:54:15 GMT - stdedos: attachment set


Fri, 07 Feb 2020 11:33:24 GMT - Antoine Martin: owner, status changed

The comtypes bits are here:

2020-02-07 11:49:57,230 Could not import comtypes.gen, trying to create it.
2020-02-07 11:49:57,230 Creating comtypes.gen package failed: [WinError 3] The system cannot find the path specified: 'C:\\Users\\user-win\\Documents\\xpra-clients\\Xpra-Python3-x86_64_4.0-r24952\\lib\\library.zip\\comtypes\\gen'
2020-02-07 11:49:57,230 Created a memory-only package.
2020-02-07 11:49:57,230 Creating writeable comtypes cache directory: 'C:\Users\STAVRO~1.NTE\AppData\Local\Temp\4\comtypes_cache\Xpra_cmd-38'
2020-02-07 11:49:57,230 Using writeable comtypes cache directory: 'C:\Users\STAVRO~1.NTE\AppData\Local\Temp\4\comtypes_cache\Xpra_cmd-38'
2020-02-07 11:49:57,246 Could not import comtypes.gen._565783C6_CB41_11D1_8B02_00600806D9B6_0_1_2: No module named 'comtypes.gen._565783C6_CB41_11D1_8B02_00600806D9B6_0_1_2'
2020-02-07 11:49:57,246 # Generating comtypes.gen._565783C6_CB41_11D1_8B02_00600806D9B6_0_1_2
2020-02-07 11:49:57,277 Could not import comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0: No module named 'comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0'
2020-02-07 11:49:57,293 # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0
2020-02-07 11:49:57,324 Could not import comtypes.gen.stdole: No module named 'comtypes.gen.stdole'
2020-02-07 11:49:57,324 # Generating comtypes.gen.stdole
2020-02-07 11:49:57,402 Could not import comtypes.gen.WbemScripting: No module named 'comtypes.gen.WbemScripting'
2020-02-07 11:49:57,402 # Generating comtypes.gen.WbemScripting

This looks like an upstream bug: ModuleNotFoundError: No module named 'comtypes.gen.stdole'

The fix seems to be here: Fix importing newly-created modules on Python 3.

I will try to build a new comtypes package with this patch included.


Fri, 07 Feb 2020 13:12:03 GMT - Antoine Martin: owner, status changed

Created a pull request: comtypes: include patch from upstream to fix missing module errors and I've uploaded a r25179 build with the updated comtypes package.

Does that work better for you? (the error is a race condition - so it may just come and go away on its own..)


Mon, 10 Feb 2020 10:31:51 GMT - stdedos:

Apparently, beta is missing the zip packages :/

https://www.xpra.org/beta/windows/?C=M&O=D&P=*r25*.zip*


Mon, 10 Feb 2020 10:52:50 GMT - stdedos:

I keep trying to downgrade to get a usable Windows client, but it's not happening - I keep getting flooded with:

2020-02-10 12:51:09,285 Could not import comtypes.gen, trying to create it.
2020-02-10 12:51:09,285 Creating comtypes.gen package failed: [WinError 3] The system cannot find the path specified: 'Xpra-Python3-x86_64_4.0-r24803\\lib\\library.zip\\comtypes\\gen'
2020-02-10 12:51:09,285 Created a memory-only package.
2020-02-10 12:51:09,301 Using writeable comtypes cache directory: '%AppData%\Local\Temp\5\comtypes_cache\Xpra_cmd-38'
2020-02-10 12:51:11,324 Error: failed to receive anything, not an xpra server?
2020-02-10 12:51:11,324   could also be the wrong protocol, username, password or port
2020-02-10 12:51:11,340   or the session was not found
2020-02-10 12:51:11,340 Connection lost

Mon, 10 Feb 2020 13:30:13 GMT - Antoine Martin:

Apparently, beta is missing the zip packages :/

Ooops, try now.

This fix is included in the latest 3.0.6 stable release for win32 (r25205). There are also beta 4.0 ZIP packages now.

I keep getting flooded with: (..) 2020-02-10 12:51:11,324 Error: failed to receive anything, not an xpra server?

Are you sure that the problem is client side?


Mon, 10 Feb 2020 13:55:09 GMT - stdedos:

Replying to Antoine Martin:

I keep getting flooded with: (..) 2020-02-10 12:51:11,324 Error: failed to receive anything, not an xpra server?

Are you sure that the problem is client side?

You are right: probably it hasn't connected at all:

$ ls -lah /run/user/1000/xpra/
total 8,0K
drwx------  2 u u   60 Φεβ  10 15:52 .
drwx------ 14 u u  420 Φεβ  10 15:31 ..

I'll just try with the newest builds; no reason to keep with older builds I guess


Tue, 11 Feb 2020 19:22:46 GMT - stdedos:

Blocked on #2588; Xpra-Python3-x86_64_4.0-r24762 gives:

2020-02-11 21:21:52,905 Could not import comtypes.gen, trying to create it.
2020-02-11 21:21:52,909 Creating comtypes.gen package failed: [WinError 3] The system cannot find the path specified: 'Xpra-Python3-x86_64_4.0-r24762\\lib\\library.zip\\comtypes\\gen'
2020-02-11 21:21:52,913 Created a memory-only package.
2020-02-11 21:21:52,917 Creating writeable comtypes cache directory: '%AppData%\Local\Temp\6\comtypes_cache\Xpra_cmd-38'
2020-02-11 21:21:52,921 Using writeable comtypes cache directory: '%AppData%\Local\Temp\6\comtypes_cache\Xpra_cmd-38'
2020-02-11 21:21:52,961 Could not import comtypes.gen._565783C6_CB41_11D1_8B02_00600806D9B6_0_1_2: No module named 'comtypes.gen._565783C6_CB41_11D1_8B02_00600806D9B6_0_1_2'
2020-02-11 21:21:52,965 # Generating comtypes.gen._565783C6_CB41_11D1_8B02_00600806D9B6_0_1_2
2020-02-11 21:21:53,013 Could not import comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0: No module named 'comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0'
2020-02-11 21:21:53,017 # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0
2020-02-11 21:21:53,069 Could not import comtypes.gen.stdole: No module named 'comtypes.gen.stdole'
2020-02-11 21:21:53,069 # Generating comtypes.gen.stdole
2020-02-11 21:21:53,153 Could not import comtypes.gen.WbemScripting: No module named 'comtypes.gen.WbemScripting'
2020-02-11 21:21:53,157 # Generating comtypes.gen.WbemScripting
2020-02-11 21:21:56,009 enabled remote logging
2020-02-11 21:21:56,009 Xpra GTK3 shadow server version 3.0.6-r25174 64-bit
2020-02-11 21:21:56,025  running on Linux Ubuntu 16.04 xenial

Wed, 12 Feb 2020 04:41:06 GMT - Antoine Martin:

Blocked on #2588

IIRC, the latest 3.0.6 release builds also have this fix.

Xpra-Python3-x86_64_4.0-r24762 gives:

That's older than the fix. That said, there's no error in that output, which can happen since the bug was a race condition in python-comtypes.


Wed, 12 Feb 2020 13:27:50 GMT - stdedos: status changed; resolution set

Seems that Xpra-Python3-x86_64_4.0-r25205 is working all of a sudden :/

Also, this is now fixed.


Thu, 12 Mar 2020 14:53:03 GMT - totaamwin32: status changed; resolution deleted

It's happening again, and it looks like a comtypes bug:

2020-03-12 15:40:02,807 Could not import comtypes.gen, trying to create it.
2020-03-12 15:40:02,807 Creating comtypes.gen package failed: [WinError 3] The system cannot find the path specified: 'E:/Xpra/trunk/src/dist/lib/library.zip/comtypes/gen'
2020-03-12 15:40:02,807 Created a memory-only package.
2020-03-12 15:40:02,807 Using writeable comtypes cache directory: 'C:/Users/WIN7PR~1/AppData/Local/Temp/comtypes_cache/xpra_cmd-38'
2020-03-12 15:40:02,823 get_interface_info({DDE35DAB-A010-4150-B02D-6C4191D81842})
Traceback (most recent call last):
  File "E:\Xpra\trunk\src/xpra/platform/win32/netdev_query.py", line 18, in get_interface_info
    o = CreateObject("WbemScripting.SWbemLocator")
  File "C:/msys64/mingw64/lib/python3.8/site-packages/comtypes/client/__init__.py", line 250, in CreateObject
    return _manage(obj, clsid, interface=interface)
  File "C:/msys64/mingw64/lib/python3.8/site-packages/comtypes/client/__init__.py", line 188, in _manage
    obj = GetBestInterface(obj)
  File "C:/msys64/mingw64/lib/python3.8/site-packages/comtypes/client/__init__.py", line 112, in GetBestInterface
    interface = getattr(mod, itf_name)
AttributeError: module 'comtypes.gen.WbemScripting' has no attribute 'ISWbemLocator'
2020-03-12 15:40:02,823 Error: failed to query network interface:
2020-03-12 15:40:02,823  module 'comtypes.gen.WbemScripting' has no attribute 'ISWbemLocator'

Because calling CreateObject("WbemScripting.SWbemLocator") should work: SWbemLocator.ConnectServer method. The same code does work from an MSYS2 shell:

>>> from comtypes import CoInitialize
>>> CoInitialize()
>>> from comtypes.client import CreateObject        #@UnresolvedImport
>>> o = CreateObject("WbemScripting.SWbemLocator")
>>> o
<POINTER(ISWbemLocator) ptr=0x9ff13d0 at 9f10e40>

So maybe it's just not happy when running from a memory-only package?

Unfortunately, python-comtypes is not very active at all, no releases since 2018... So maybe we'll have to use something else.

For now, r25617 makes this error less scary.


Thu, 19 Mar 2020 15:49:02 GMT - Antoine Martin: milestone changed

out of time


Sun, 04 Oct 2020 12:41:23 GMT - Antoine Martin: milestone changed

Not much happening with comtypes..


Sat, 23 Jan 2021 05:54:58 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2573