Why I have this error: ModuleNotfound error python3

Why I have this error: ModuleNotfound error python3

我的项目有下一个结构:

structure

我正在尝试 运行 具有以下内容的文件 tests/test.py:

import unittest
from machinetranslation.translator import english_to_french, french_to_english

class TestMain(unittest.TestCase):

    def test_EnglishToFrench(self):
        test_case = "Hello"
        expected = "Bonjour"        
        self.assertEqual(english_to_french(test_case), expected)

    def test_FrenchToEnglish(self):
        test_case = "Bonjour"
        expected = "Hello"        
        self.assertEqual(french_to_english(test_case), expected)

    def test_EnglishToFrench_null(self):
        test_case = None
        expected = "Type a text in English"
        self.assertEqual(english_to_french(test_case), expected)

    def test_FrenchToEnglish_null(self):
        test_case = None
        expected = "Type a text in French"
        self.assertEqual(french_to_english(test_case), expected)


if __name__ == '__main__':
    unittest.main()

但我不知道为什么会收到错误消息:“ModuleNotFoundError:没有名为 'machinetranslation' 的模块” 谁能告诉我为什么会出现这个错误,谢谢

我以前也遇到过这个问题,这对我有帮助:

import os, sys
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)

// Import files here