Jupyter-Äquivalent von sys.path[0] (wie man das Verzeichnis der Notebook-Datei erhält)

In Jupyter gibt

jupyter_syspath_example.py
import sys
sys.path[0]

nicht das Verzeichnis zurück, in dem sich die Notebook-Datei befindet, sondern etwas wie

jupyter_syspath_output.txt
/usr/lib/python310.zip

Verwenden Sie stattdessen

jupyter_notebook_dir.py
import os.path

os.path.dirname(os.path.realpath("__file__"))

Check out similar posts by category: Jupyter, Python