✈️

[Jupyter notebook]ルートディレクトリの遡っての指定

2025/01/05に公開

絶対パスから遡ってプロジェクトディレクトリを指定する。
osとsysが必要。
上がりたい階層だけ..を繰り返す。

project_root = os.path.abspath('../..')
if project_root not in sys.path:
    sys.path.append(project_root)

Discussion