0

I added a git submodule to my project that I don't want to change because I am not the maintainer. I would like to use the python files of that project but from the files of my project. The situation is similar to the following:

github_module
  - submodule
    - file_2.py
  - file_1.py
my_project.py

The projects uses imports relative to that project (e.g. file_1.py contains: import submodule.file_2), but I would like to use file_1.py from my_project.py. However if I use it with: import github_module.file_1 the interpreter throws a ModuleNotFoundError: No module named 'submodule'.

I know that a possible solution is to change the import submodule.file_2 with import github_module.submodule.file_2. But I would like to not change the github_module. Is there another way?

Damien
  • 921
  • 4
  • 13
  • 31
  • The solution is here: https://stackoverflow.com/questions/29746958/how-to-import-python-file-from-git-submodule – Damien Feb 22 '23 at 14:27

0 Answers0