Jupyter can’t find python imports in same directory

the reason why your sys.path.append statements have no effect is that you start the paths with a trailing “/”, which indicates that they are absolute paths, even though they should not be.

You could either add the full paths to the modules you would like to import or, if you want to use relative paths, do something like this:

import os
sys.path.append(os.path.join(os.path.abspath(os.getcwd()), "networks"))

Here, os.path.abspath(os.getcwd()) computes the absolute path of the current working directory and os.path.join joins it with your relative path afterwards.

Best, Homan

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top