Making Python code safe for file paths
info-rchitect
Registered Posts: 188 ✭✭✭✭✭✭
Hi,
When running code that uses the `Pathlib` library in a dataiku jupyter notebook, I am getting errors because it cannot find the files as it can when I run in regular Python.
# self.controller.config is a Path instance self.credentials_file = self.controller.config_dir / 'snowflake_credentials.yaml'
Operating system used: Windows 10
Tagged:
Answers
-
Hi @info-rchitect
,I've done some experimenting with pathlib on my end, but I haven't experienced any errors.
Could you please provide a complete code example and the error message that you're getting so that I can better help you?
Thanks,
Zach
-
ZachM,
The issue is when trying to debug code in Jupyter notebook vs running in a webapp or a recipe. I solved the problem by ditching `Pathlib` and just using `os`:
os.path.dirname(os.path.realpath(__file__))