I tried all of the above but nothing worked.
On the other hand, below you can find a quick solution that worked for me:
notebook_path = IPython.get_ipython().user_ns.get("__vsc_ipynb_file__")
I suspect this only works if you are using VSC as your ide.