I have literally been trying to figure out how to export multiple environment variables without having to type them one by one in the terminal and you are the only person that has actually giving me the answer. Thank you so much!!!
Hi Beat Boss. I think I mentioned in the video that the commands I was using will only work on Linux and you'd need to check the ones for Windows. www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-windows-command-line-and-registry/ - This tutorial looks pretty good, but I don't know the Windows world very well.
Hey, thanks this really helped me out. Just curious, if we use git, wouldn't be people able to see the venv/bin/activate file and therefore, the variables inside?
Hi! (I need to sort out these comment notifications). You actually raise a very important point. You want to always exclude/ignore the `env` or `venv` folder from Git in y our `.gitignore`. Like you said, security wise, but also otherwise it makes your Git repository unnecessary big.
At last someone explained how to work with env vars in venv. BTW, can you please tell where are these variables are stored? If I'm exporting in venv or if I'm exporting outside venv in a normal bash. Also is there a way to save variable in the activate file with our browsing it with nano? like some sort of persistent export command inside venv?
Appreciate the question Timur. LOCATING ENV VARS So when you create a virtual environment, it shouldn't be pulling in any outside environment variables. That's the idea of a virtual environment, it's an isolated world. But, in general environment variables are pulled from many different files. I don't know Windows very well but in Linux, this answers it well... askubuntu.com/a/164590 CREATING PERSISTENT ENV VARS You CAN save the variables in the activate file. So we're obviously used to activating the virtual environment by doing something like... "source env/bin/activate" (on Linux if your virtual environment folder is called "env"). But, like you said, activate is just a file. So if you open it using nano, `nano env/bin/activate`... Then you can add any extra commands to do (because it's essentially just a script of terminal commands). E.g. you want to add a variable called "API_KEY". Then at the end of the activate file you'd add... `export API_KEY="123abc"` And whenever you activate the virtual environment, API_KEY will be an available env var
@@aashisahu6232 I'm not actually sure to be honest, could be a Windows specific thing. And environment variables are pulled from multiple places as well.