'Python3: Import Module over Package
I'm looking for suggestions to import a module over a package in Python3. I don't have control over the names of the files so changing them is not an option. Additionally, the submodules are external github repositories that I will constantly pull updates from, hence cannot change the contents of feature.py
This is my directory structure:
foo
__init__.py
bar_1.py
bar_2.py
submodules
s_module_1
foo.py
feature.py
s_module_2
s_module_3
main.py
Contents of feature.py
...
from foo import foo_methods # import from foo.py module
...
Contents of main.py
from foo import * # imports from foo package
import sys
sys.path.insert(0, 'submodules/s_module_1')
from feature import * # results in error
When I run main.py, the error I get is
ImportError: cannot import name 'foo_methods' from 'foo' (foo/__init__.py)
Any suggestions to resolve this would be appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
