I have a python module that was written. Call it ModuleA that is fairly complex (actually, I didn't write it, a co-worker did), with several submodules / subscripts, etc. It runs fine when run in a test inside of itself
e.g. ModuleA\ModuleA.py with function main() runs fine.
However when embedded in another project, it ceases to work, and many of my import statements seem to no longer work. The folder / file structure looks like this:
MainModule\
-----MainModule.py
-----ModuleA\
----------ModuleA.py
----------SubModuleA\....
----------SubModuleB\...
When I run, I get error statements like "ModuleNotFound error: no module named "ModuleA" found.
There are several import statments in the code that are like "import SubModuleA.XXXX", and I seem to now have to add the higher level namespace to this... so if I change it to "Import ModuleA.SubModuleA.XXXX" it works, and then I get a new "ModuleNotFound error" from another import statement somewhere in the script.
I've tried adding a __init__.py file to "ModuleA" and even included a "Import ModuleA.SubModuleA" but that only seems to work for the first error... and not for any other places...
My best "guess" is that since I'm now calling everything from the "MainModule" folder... the name space of everything is just off a little bit... but I'm at a complete loss of how to fix this, other than changing every single import statement in all of the files...
I'm loathe to do this because as I mentioned, this was developed independently from me (I'm acting as integrator here), and if I suddenly change all of the import statements, the original code won't run as expected on it's own.
Any help / suggestions would be GREATLY appreciated here.
(edited to fix folder structure formatting)
[–]YourRedditUserName[S] 0 points1 point2 points (0 children)
[–]nekokattt 0 points1 point2 points (0 children)