Repository navigation
Suggest the possible module in ModuleNotFoundError #134175
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on May 18, 2025 Locked-chess-official commented
on May 18, 2025 ContributorAuthorMore actionsOk. Maybe some module cannot be imported by the current interpreter. If the Exception raise by this (name is in the "available_modules") maybe we need to suggest another message.
- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directoryand removedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on May 18, 2025 cc @tomasr8
It won't be as easy,
importlibis frozen,pkgutilis not. IIRC it only had one dependency,sys.It's not about being frozen, it's more about the fact that it can be very slow to iterate over millions of installed packages just to find a match as the namespace to look in is the "entire" site-packages in this case.
Reacted by Stan Ulbrych- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on May 18, 2025 it's more about the fact that it can be very slow to iterate over millions of installed packages
That too:-)
Locked-chess-official commented
on May 18, 2025 ContributorAuthorMore actionsI think that we can distinguish the grade to compare.
First is the builtin-module.
Second is the standard module.('Lib')
Third is the project module.
Finally is the site-packages.('Lib/site-package')It can solve some of the speed problem.
It's not about being frozen, it's more about the fact that it can be very slow to iterate over millions of installed packages just to find a match as the namespace to look in is the "entire" site-packages in this case.
Locked-chess-official commented
on May 18, 2025 ContributorAuthorMore actionsAnd we don't need to compare for the pypi packages that wasn't installed.
Locked-chess-official commented
on May 18, 2025 ContributorAuthorMore actionsIf there is too many site-packages, the solution might be create the virtual environments.
Locked-chess-official commented
on May 18, 2025 ContributorAuthorMore actionsIt's not about being frozen, it's more about the fact that it can be very slow to iterate over millions of installed packages just to find a match as the namespace to look in is the "entire" site-packages in this case.
And if that's True, the size of the python might be between 1T to 12T, whith means that the computer cannot run any other things, can only be as a docker, I think.
Actually, we could perhaps use #129329. However, it appears that we're building a global cache anyway, so it may not be impossible after all.
In addition, now that I think about, we should probably only need to present suggestions for top-level packages and leave the rest to attribute suggestion when possible.
- addedtopic-replRelated to the interactive shellRelated to the interactive shelland removedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on May 18, 2025 - addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)and removedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shell
on Aug 9, 2025 I'm closing this one because the cache needs to be built at the interpreter's level which is not a good idea due to resources managements and references being held. The REPL autocompletion works well because the cache is at the REPL level but suggestions are constructed in C.
Locked-chess-official commented
on Aug 9, 2025 ContributorAuthorMore actionsI'm closing this one because the cache needs to be built at the interpreter's level which is not a good idea due to resources managements and references being held. The REPL autocompletion works well because the cache is at the REPL level but suggestions are constructed in C.
Ok. The ideal is based on that 'it need a cache'. Well, the
pkgutildon't need to import any packages, just analyses and it is fast. What you are worried is that "if there is too many packages". However, in my computer, there are only hundreds of packages and it is still fast, while 2/3 of the storage space of the computer has been occured(alomost 600/900gb), so the normally computer cannot install millions of packages. In this case, I'm suspected that whether the cache is needed.
Feature or enhancement
Proposal:
When import the module, it will raise ModuleNotFoundError if the word is wrong. Like NameError, we can suggest the module name that might be right.
>>>import ant Traceback (most recent call last): File <stdin> line 1, in <module> import ant ^^^ ModuleNotFoundError: no module named 'ant'. Did you mean 'ast'?To get all of the module, this function can get:
Just need to compare the most likely module name and suggest.
Note: only when the ModuleNotFoundError was raised by python interpreter instead of raise active
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response