0

I've run into an import issue in my library, when trying to replicate the notebooks behavior in SHAP. In this case, a Juypter Notebook in the notebooks directory includes import shap, where the shap package includes all of the functionality.

My library has a similar structure, where I have import package. This package has an __init__.py file, but the following error occurs

ModuleNotFoundError: No module named 'package'

The fix is likely trivial, but I have not been able to work it out.

File structure:

dir  
 |  
 +--notebooks  
 |      |  
 |      +--foo.ipynb  
 |  
 +--package  
        |  
        +--__init__.py  
        |  
        +--subpackage1  
        |  
        +--subpackage2  

Both subpackage1 and subpackage2 have an __init__.py file.

sunspots
  • 1,047
  • 13
  • 29
  • 1
    Can you describe your folder structure (where files are located): the script you want to execute and the package – Jean-Marc Volle May 16 '20 at 13:50
  • Personnally, I use `sys.path.insert(0, os.path.abspath('..'))` in my `init.my` files to solve this kind of issue. – pyOliv May 16 '20 at 19:10

0 Answers0