Re: Python dependencies in add-ons

Rui Fontes

Sorry, but to import a module present in the same folder of the .py file, the syntax is not:

from . import modul

Rui Fontes

Às 14:05 de 09/06/2020, Cyrille via escreveu:

Hi Andy

Some thoughts, I did not test by myself however.

Maybe you should insert the path containing the html library at the beginning of the path and not at the end to ensure that this version of html library is fetched:
sys.path.insert(0, addonNamePath)
import html.parse
del sys.path[0]

Moreover, it seems that doing as you wrote, you get twice the add-on's path in sys.path. One time added by NVDA to import your add-on and a second time in the code of your add-on. I do not know if putting twice the addonpath in sys.path may generate side effect or difficulties in debug regarding import. An alternative solution is to put your html library in a "lib" subfolder and add/remove this subfolder's path.

Again, I have not tested all this by myself; it is just thoughts that came to my mind when I read your message. Hope it can help.



Le 09/06/2020 à 14:22, Andy B. a écrit :

I did the following to see if this would work:


  • Copied the html library from python3/lib install path and put it in my addon install folder.
  • Added the lines below to the top of my addon file:
  • import os
  • import sys
  • addonNamePath = os.path.abspath(os.path.dirname(__file__)) #addon folder path
  • sys.path.append(addonNamePath)
  • import html.parser
  • del sys.path[-1]

I either get module not found errors or syntax errors because relative imports aren’t allowed. Doing the same to the lxml library works as expected. However, it depends on html.parser which NVDA removed from the html library.


Sent from Mail for Windows 10


From: Shaun Everiss
Sent: Tuesday, June 9, 2020 5:53 AM
Subject: Re: [nvda-addons] Python dependencies in add-ons


Well just remember guys that while this may not become that important in say another few years, nvda is used on a lot of systems.

Not everyone has the latest and greatest and not everyone can have the latest and greatest of systems depending where they are especially now.

I know quite a few with win7 and yes xp.

While nvda latest doesn't matter in this reguard, even if we take in to mind that at minimum your system will have 4gb of ram, 30mb could be a lot to someone.

And even if this is excluded, not everyone has an ssd.

And even if that is excluded also not everyone will have the best cpu.

I know at least a few using 3rd generation intel systems and older amd systems.

I myself maintain a 3700, a i530, a 7200, and a 4500 and I know that in the second hand systems part of my tech store they are still trading crappy 2nd generation systems.

Even though a laptop of reasonable design costs between 800 and 1000 bucks easily, some can't afford it and will use older tech.

They will use it till it dies.

And even if that is not a problem not everyone even in my country has fibre.

Some have wireless, lite fiber, some still use dialup.

So while thats not many 30mb may matter.

At first I was like just load it all in, but thats why the core package never has everything in it.

In fact nvda is designed for modules to be installed.

No one needs everyone of them, but everyone has a certain subset.

So for me I have enough for all the programs that use one of course, including the os, and a few extra utilities I like.

In the home network systems, I have enough for the systems to work as well as apps on those if I need but a lot less.

In the systems I administrate though which are not mine including family servers, the only modules I have are the modules I absolutely need.

Then again if you think extra stuff is needed then it is needed.



On 9/06/2020 9:30 pm, Sean wrote:

I know that the NVDA team wants to keep the size of NVDA to a minimum.
This is important for use as a portable.

I think the pure python code doesn't take up much size.
The .pyd files of this type of modules are very size large.
If there are problems with file sizes, this can be reduced with UPX.
After all, 20-30 MB of RAM is used more, but it is an efficient method.

I wish you good coding...
As the work emerges, great ideas will continue to come from here.

On 09/06/2020 11:28, Shubham Jain wrote:

Hi Sean!

This seems like a fairly simple solution! The weights of the model already take up a lot of space (~150-200 Mb) and some of these libraries are ~50 Mb in size so I might need to get rid of all the unnecessary parts of the library to reduce space. Since I only require little functionality from these libraries, it would help with that too.

Your English is great and your explanation was very clear! Many thanks.

Shubham Jain



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


Join to automatically receive all group messages.