cannot access modules from neighbouring directories jupyter notebook 1

cannot access modules from neighbouring directories jupyter notebook

import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
    sys.path.append(module_path)
# and add __init__.py to the modules

Here is what the above code is Doing:
1. We’re importing the os module, which allows us to interact with the operating system.
2. We’re importing the sys module, which allows us to access command-line arguments.
3. We’re creating a variable called module_path and setting it equal to the path of the directory that contains the file we’re currently running.
4. We’re checking to see if module_path is already in sys.path. If it isn’t, we append it.

Similar Posts