Page 1 of 1

about pywin32

Posted: 09.01.2024 08:06
by SamC
Recently, I'm writing a plugin which need to import the win32com.client module.
Then, I notice there is a plugin 'plugin.pywin32.zip' in the '\CudaText_addons\plugin', I install it, but the import raise the error below:
"ModuleNotFoundError: No module named 'win32com'
ERROR: Exception in CudaText: ModuleNotFoundError: No module named 'win32com'"
Then I check the readme.txt of that plugin, it says below. It seem it's for python3.6, and the python in cuda is 3.8, is that the reason for the error? Or I misunderstanding this plugin?
'Library "pywin32" and its requires libraries.
From https://github.com/mhammond/pywin32/releases
for Python 3.6.'
Thanks!

BTW, can markdown be used in this forum?

Re: about pywin32

Posted: 09.01.2024 08:34
by main Alexey
markdown cannot be used. forum uses BBCode as I know.

pywin32 plugin is outdated, no one used it for ages. can you update it for Py3.8 (then test it) and send me the .zip?
support(at)uvviewsoft.com

Re: about pywin32

Posted: 09.01.2024 09:59
by SamC
main Alexey wrote: 09.01.2024 08:34 markdown cannot be used. forum uses BBCode as I know.

pywin32 plugin is outdated, no one used it for ages. can you update it for Py3.8 (then test it) and send me the .zip?
support(at)uvviewsoft.com
I do some test, it seems the installed pywin32 is with multi packages and also with a pywin32.pth file on the /site-packages folder, the context is below. I copy these all in cuda's py folder.
The import is with error that pywintypes.py can't be founld which is in the win32\lib folder.
I suppose maybe cuda didn't read the *.pth file, so the pywintypes.py is not found because not directly in the /py folder? Then the dependence is wrong?
# .pth file for the PyWin32 extensions
win32
win32\lib
Pythonwin
# This breaks any software involving a feedback loop involving PATH and Python
# One example of such software is the Anaconda Distribition's conda package
# manager, so we do not do it. We fixed this in a slightly better way anyway.
# import pywin32_bootstrap

Re: about pywin32

Posted: 09.01.2024 10:03
by main Alexey
yes, Cud don't read .pth files at all. it needs all modules in the 'sys.path' folders. and win32\lib is not in 'sys.path'.
maybe you can move files from win32\lib to upper dir?

Re: about pywin32

Posted: 09.01.2024 10:15
by SamC
main Alexey wrote: 09.01.2024 10:03 yes, Cud don't read .pth files at all. it needs all modules in the 'sys.path' folders. and win32\lib is not in 'sys.path'.
maybe you can move files from win32\lib to upper dir?
May I add some folder in sys.path of cuda?

Re: about pywin32

Posted: 09.01.2024 10:22
by main Alexey
some plugins modify 'sys.path' when they have COMPLEX modules to import.

Re: about pywin32

Posted: 09.01.2024 10:23
by main Alexey
e.g. LSP plugin

Code: Select all

import sys
_plugin_dir = os.path.dirname(os.path.realpath(__file__))
#sys.path.append(os.path.join(_plugin_dir, 'lsp_modules'))
# instead of append use insert
sys.path.insert(0, os.path.join(_plugin_dir, 'lsp_modules'))