Reputation: 64346
I have modules written in c++ for python. For example, here is folders structure:
|Main/
|--SubMain/
|----Module1.so
|--SubMain2/
|----Module2.so
|----Module3.so
Now I want to import this into python like:
import Main.SubMain.Module1
First of all, I did recursively for all that folders:
import sys
sys.path.append(...)
And now I can do:
import Module1
import Module2
import Module3
But I want to specify the exact folder of the module. I tried to put __init__.py
into all folders but this didn't help me. This way modules aren't visible for python. What's wrong?
Upvotes: 0
Views: 1097
Reputation: 42694
In order to make something a package, you need to add __init__.py
(not __input__.py
) to the folders. So if you add __init__.py
to Main, Submain1, and Submain2, then call sys.path.append with the parent of Main, you should be able to import as you desire.
Upvotes: 2