My existing python script is in the One Drive and I want to get its path. I have tried all the solutions but none of them worked.
This code did not work at all.
import os
sys.getcwd()
It brought C"\users\hkay. My python file is in the one drive. The closest solution was this one.
from inspect import getsourcefile
from os.path import abspath
abspath(getsourcefile(lambda:0))
This solution seems to bring the downloaded version of OneDrive in the temporary folder as shown below but the file is actually in OneDrive in C:\Users\hkay\OneDrive\Desktop\Project A\
'D:\TEMP\hkay\Temp\ipykernel_179044\1451747622.py'