I know similar questions have been asked many, many, many, many times.
I read them thoroughly and tried plenty of solutions but apparently I can't find a way to make it work for me. So I believe this question is not a duplicate.
I have the following structure:
+ C:\etc.\etc.\maindir <---Root Directory
| mymainfile.py
| __init__.py <---this is empty
+ \AuxFun <--- Subfolder
| __init__.py <---this contains: "from . import *"
| myauxfun1.py
| myauxfun3.py
Now, inside my main (mymainfile.py
) I have:
from AuxFun.myauxfun1 import AuxFun1
import AuxFun.myauxfun3 as AuxFun3
each myauxfun
consists of a single function :
def fun()
...
return output
The script works perfectly on jupyter notebook 5.6.0 with Python 3.7 (and IPython 6.5)
However it doesn't work on Spyder 3.3.1 with Python 3.7.
and when trying to import, the console returns:
ModuleNotFoundError: No module named 'AuxFun'
I originally tried without any __init__.py
file and with a totally empty __init__.py
in the subfolder.
I also tried the following:
from AuxiliaryFunctions import *
from .AuxFun.myauxfun1 import AuxFun1
import KR.AuxFun.myauxfun2 as AuxFun2
which return respectively:
ModuleNotFoundError: No module named 'AuxiliaryFunctions'
ModuleNotFoundError: No module named '__main__.AuxiliaryFunctions'; '__main__' is not a package
ModuleNotFoundError: No module named 'KR'
Interestingly (for me) the autocompletion recognizes the folder and files.
i.e. if I type: ".
⇥ Tab" the AuxFun
subfolder appears.
Alike, typing ".AuxFun.
⇥ Tab" will display all the auxfun scripts within the subfolder.