Skip to content Skip to sidebar Skip to footer

Python 3 ModuleNotFoundError: No Module Named 'lot'

I am trying to run a python3 unit test script but it gives me a module not found error when it uses objects from the main scipt and comes across import statements. I don't face thi

Solution 1:

As python 3 doesn't support Implicit relative import. You can use explicit relative import.

Try using the following line instead of import lot in parking.py

from . import lot


Solution 2:

in the same directory level file when you import the one file in another use relative import like

in parking.py file importing lot.py file as

import .log

and when import from one directory to lower directory ie importing lot in parkingLot_test.py, use from source import lot

and in the source folder in __init__.py file write

import .lot
import .parking

like this.


Post a Comment for "Python 3 ModuleNotFoundError: No Module Named 'lot'"