#🔒 Storing persistent env vars
36 messages · Page 1 of 1 (latest)
@near lichen
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
i recommend using a dotenv file and this library to read/write to it
if you're using git, make sure the dotenv file is in the .gitignore
i have created an env so should i replace it?
is spo.py your project?
yes
ok 2 things:
your project should be a folder containing your virtual environment and your source code (and whatever else is needed for the project), your source code shouldn't be inside your virtual environment (that's what spotify-env is)
so it should be something like
my-spotify-project
env
bin
blah blah
spo.py
oh right, i just watched the spotipy tutorial on how to set it up
ok ill sort that out
secondly, the virtual environment is a totally different thing that a .env file (I know it's confusing with the similar terms)
like this?
yeah
alright
your OS keeps track of some environment variables, which you can use to store private credentials
the dotenv module allows you to load a .env file as if its contents were from the OS environment
storing them in a file this way makes them a little easier to see and edit and keeps from polluting the global environment
adding the .env file to .gitignore makes sure you dont publish your private credentials along with your source code
that would go in the top level of your project folder, but its only relevant if you're using git
also at the top level
you shouldnt put anything inside the virtual env, that's just a copy of a python interpreter for your project to use
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.