0

I have a Python project, that uses some code from a Github repo. I added the repo using git submodule add. So now I have the following file-structure:

ProjectFolder\
    foo.py
    BarProject\ (the Github repo added with submodule)
        bar.py
        baz.py

In my main file foo.py I want to import the method bar from the file bar.py:

from BarProject.bar import bar

This fails, because the first line of bar.py is :

from baz import *

And Python throws an ImportError, because it cannot find the module baz.


Is there a way to import the file bar.py in a way, so that the relative imports don't get screwed up? I don't really want to modify bar.py or baz.py, because they are part of an external Github project.

Jakube
  • 3,353
  • 3
  • 23
  • 40

1 Answers1

0

remember to add __init__.py to BarProject folder to indicate that folder is a package.

Rich Tier
  • 9,021
  • 10
  • 48
  • 71