In python3.8, what's the difference between ImportError
and ModuleNotFoundError
? I'm just wondering what the difference is and why they matter.
ModuleNotFoundError
is a kind of ImportError
:
>>> issubclass(ModuleNotFoundError, ImportError)
True
It's raised specifically when the module cannot be found at all. Other problems can occur after the file is found, but during the actual process of loading the file or defining the function: those would raise ImportError
.
There's probably not much you can do about a ModuleNotFoundError
; you can either ignore it and not use the module you tried to import later in the code, or exit and fix your environment so that the module will be found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With