reddit / emacs

How to handle credentials for Python in Emacs

suhrob · 2022-08-12 07:17
Ideally, I'd like to get credentials (e.g. for API endpoints) from my environment when developing in python. However Emacs doesn't see them (I don't run it from terminal). Now there is the package `exec-path-from-shell` that loads the `PATH` variable and that's nice and dandy. But I need other variables (possibly dozens of APIs for different projects). Is there any reasonable way to do it? Thank you!
[deleted] · 2022-08-12 07:28
[deleted]
suhrob · 2022-08-12 08:28
Thank you! Apologies that it was essentially a RTFM question... I somehow skipped over the paragraph...
vifon · 2022-08-13 22:38
Alternatively to what /u/hantva said, you can try using [direnv](https://github.com/wbolster/emacs-direnv) and its integration with Emacs. This has a benefit of scaling better if you have more than one such project as each set of env vars is separate.
kisharrington · 2022-08-14 14:03
This. Relatedly, [https://pypi.org/project/python-dotenv/](https://pypi.org/project/python-dotenv/) for using the .env variables on the Python side.