Search code examples
pythonpython-3.xpython-import

Python3.8: What's the difference between ImportError and ModuleNotFoundError


In python3.8, what's the difference between ImportError and ModuleNotFoundError? I'm just wondering what the difference is and why they matter.


Solution

  • According to the python docs:

    The ImportError is raised when an import statement has trouble successfully importing the specified module. Typically, such a problem is due to an invalid or incorrect path, which will raise a ModuleNotFoundError in Python 3.6 and newer versions.