Well, modulenotfounderror itself says module not found. Means something wrong while importing modules in python script.
There can be multiple reason behind this problem
Spelling mistake in imported module name
Imported package is not installed
Path for imported packages is not found by python interpreter
Spelling mistake in imported module name
Its most common issue while importing modules there can be human typing mistake. Therefore we need to first look for spelling in module name included.
Imported package is not installed
some of the python package does not come with python installation and require to install externally using pip command.
Example:
pip install requests
Here pip command is used to install request package.
Path for imported packages is not found by python interpreter
This is also common mistake we do specially beginners. We already have respected package installed or user defined package is in another folder on a particular server path but interpreter can't find while running python script.
In such case we just need to let interpreter find path for imported packages.
We can define path for package like
import sys
sys.path.append('path_to_misc')
Another way we can do to create empty file init.py to make folder behave as a package.
from folder import module
Therefore we can import module exist in folder.
Hope it help to understand basic insight about modulenotfounderror. Please go through modulenotfounderror no module named exceptions for more detail with demonstration example code.
Top comments (0)