Topics

win32 module detected by python but not by NVDA's python development console

Jaffar Sidek
 

Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!

Sean
 

There must be another ".py" file to import win32 process in site-packages folder.
And pywin32 is a big package.

Frankly, I don't think that pywin32 can work successfully with NVDA.

On 18/07/2020 09:48, Jaffar Sidek wrote:
Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!




--

Sean

👨‍🦯 I’m student and programmer. I coding often Python, sometimes Go and rarely C++.

Lukasz Golonka
 

Hello,

On Sat, 18 Jul 2020 14:48:23 +0800
"Jaffar Sidek" <jaffar.sidek10@...> wrote:

Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!
It's not strange at all. The modules available to your installed Python
interpreter are not available to NVDA. Why should they be?
You need to copy files from PyWin32 that are required to the folder of
your add-on and then add the directory containing them to sys.path
before importing them. What are you trying to achieve? Perhaps there is
a native ctypes way to do it which doesn't involve PyWin32.


--
Regards
Lukasz

Jaffar Sidek
 

Hi.  I am writing this particular addon for an app that has mostly win32 attrebutes, and I thought that Piwin32 could help me expose their accessible potential using Iaccessible rather then UIA.  IT is just a test I am doing so far, and I might not continue on this path if I can find a more effective way.  Cheers!

On 18/7/2020 6:26 pm, Lukasz Golonka wrote:
Hello,

On Sat, 18 Jul 2020 14:48:23 +0800
"Jaffar Sidek" <jaffar.sidek10@...> wrote:

Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!
It's not strange at all. The modules available to your installed Python
interpreter are not available to NVDA. Why should they be?
You need to copy files from PyWin32 that are required to the folder of
your add-on and then add the directory containing them to sys.path
before importing them. What are you trying to achieve? Perhaps there is
a native ctypes way to do it which doesn't involve PyWin32.

Jaffar Sidek
 

HI.  The module I really need from Piwin32 is win32com because there are some attrebutes I must expose from this particular app I am writing for and I really need the win32com module in particular, unless there is another method I can use.

On 18/7/2020 4:46 pm, Sean wrote:

There must be another ".py" file to import win32 process in site-packages folder.
And pywin32 is a big package.

Frankly, I don't think that pywin32 can work successfully with NVDA.

On 18/07/2020 09:48, Jaffar Sidek wrote:
Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!




--

Sean

👨‍🦯 I’m student and programmer. I coding often Python, sometimes Go and rarely C++.

Lukasz Golonka
 

Is functionality from comtypes not sufficient for your needs?

--
Regards
Lukasz

On Sat, 18 Jul 2020 19:03:35 +0800
"Jaffar Sidek" <jaffar.sidek10@...> wrote:

HI.  The module I really need from Piwin32 is win32com because there are some attrebutes I must expose from this particular app I am writing for and I really need the win32com module in particular, unless there is another method I can use.

On 18/7/2020 4:46 pm, Sean wrote:

There must be another ".py" file to import win32 process in site-packages folder.
And pywin32 is a big package.
Frankly, I don't think that pywin32 can work successfully with NVDA.


On 18/07/2020 09:48, Jaffar Sidek wrote:

Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!



--
Sean

- <mailto:seantolstoyevski@...>Email: seantolstoyevski@...
- <https://github.com/SeanTolstoyevski/>GitHub: SeanTolstoyevski

👨‍🦯 I’m student and programmer. I coding often Python, sometimes Go and rarely C++.


Andy B.
 

Also keep in mind that NVDA can’t make use of modules that require the cython compiler or setup.py. For example, trying to use bs4, or cssutils is impossible because xml.dom requires a compiled version of etree. Unfortunately, the native python install builds it on the fly, and NVDA can’t make use of cython to compile it. Neither would NVDA know how to compile it since that isn’t its job. Remember that the built in python interpreter is an embedded version that might have restrictions/limitations. Importing a precompiled version of xml.dom might work, but I never figured out how to get python wheels to work in the NVDA context. I gather there isn’t because again, it isn’t NVDA’s job to understand eggs or wheels. The basic premise of using external libraries is this…

 

  1. Copy the required modules and all of its dependencies to a lib folder inside the addon folder: AddonName/lib
  2. In __init__.py, use sys and os modules to insert your new lib path at the beginning (index 0) of the sys.path variable.
  3. Use ImportError with try/except blocks to test for import errors.
  4. Once your external modules are imported or errors detected, remove your sys.path entry from the system.
  5. If your modules imported without errors, continue as normal
  6. If there were import errors, troubleshoot and start over.

 

I am working on a project I thought would fit into an NVDA project. However, this project goes beyond the limitations of an NVDA addon and needs a native python experience. As a last resort, have you tried using winUser? It has a lot of objects exposing the current user and their working environment.

Sent from Mail for Windows 10

 

From: Lukasz Golonka
Sent: Saturday, July 18, 2020 6:26 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] win32 module detected by python but not by NVDA's python development console

 

Hello,

 

On Sat, 18 Jul 2020 14:48:23 +0800

"Jaffar Sidek" <jaffar.sidek10@...> wrote:

 

> Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!

 

It's not strange at all. The modules available to your installed Python

interpreter are not available to NVDA. Why should they be?

You need to copy files from PyWin32 that are required to the folder of

your add-on and then add the directory containing them to sys.path

before importing them. What are you trying to achieve? Perhaps there is

a native ctypes way to do it which doesn't involve PyWin32.

 

 

--

Regards

Lukasz

 

 

 

 

Andy B.
 

What kind of win32 attributes are you looking for?

 

 

Sent from Mail for Windows 10

 

From: Jaffar Sidek
Sent: Saturday, July 18, 2020 6:58 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] win32 module detected by python but not by NVDA's python development console

 

Hi.  I am writing this particular addon for an app that has mostly win32

attrebutes, and I thought that Piwin32 could help me expose their

accessible potential using Iaccessible rather then UIA.  IT is just a

test I am doing so far, and I might not continue on this path if I can

find a more effective way.  Cheers!

 

On 18/7/2020 6:26 pm, Lukasz Golonka wrote:

> Hello,

> On Sat, 18 Jul 2020 14:48:23 +0800

> "Jaffar Sidek" <jaffar.sidek10@...> wrote:

>> Hi.  This is a strange one on me.  I have installed the win32 python module for Addon development.  However, when I tried to import the module using the NVDA python development console, I get the module can't be found error, which seems strange because I can import it and all it's components using the native python console itself.  Any thoughts?  Cheers!

> It's not strange at all. The modules available to your installed Python

> interpreter are not available to NVDA. Why should they be?

> You need to copy files from PyWin32 that are required to the folder of

> your add-on and then add the directory containing them to sys.path

> before importing them. What are you trying to achieve? Perhaps there is

> a native ctypes way to do it which doesn't involve PyWin32.