Unable to run python script, error shows ModuleNotFoundError: No module named 'src'

Below is the python script(selenium webdriver) I want to execute. But I see error is being thrown that ModuleNotFoundError: No module named 'src'. I see the module src(folder) exist. I am trying to execute this in command prompt. Can some one please help me where I'm doing wrong.

from src.pages.base_page import BasePage
from src.pages.login_page import LoginPage
import unittest

class Dispatcher(BasePage, unittest.TestCase):

def setup(self):

def login_eoc(self):

test output: C:\NASAuto\tests>py test_dispatcher.py Traceback (most recent call last): File "test_dispatcher.py", line 1, in from src.pages.base_page import BasePage ModuleNotFoundError: No module named 'src'

1 answer

  • answered 2019-06-11 22:54 Kais Tounsi

    run a command line, go to the python folder,

    python.exe import src 

    and verify if python is able to import src. If not try to reinstall this module


    You need to add that directory to the path:

    import sys

    Maybe put this into a module if you are using it a lot.

    good luck