Can 'ImportError' occur when importing a package instead of a single module?

Responsive Ad Header

Question

Grade: Education Subject: Support
Can 'ImportError' occur when importing a package instead of a single module?
Asked by:
76 Viewed 76 Answers

Answer (76)

Best Answer
(269)
Yes. The same principles apply. If you are trying to import a package (a directory containing an `__init__.py` file) and it's not in your `sys.path` or is not properly structured, you will get an `ImportError`. Ensure the package is correctly packaged and installed.