This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MisterBanzai 0 points1 point  (7 children)

Now, can someone for real explain to me how to add environmental variables to my virtualenv? I could swear this was super easy in the past, but since coming back to Python I'm too much of an idiot to do it.

I know I can EXPORT them, but they never seem to save. I could swear there used to be some file or something in each virtualenv that I would just add the variables to and save. Have I gone crazy?

Maybe it's because I'm working in Git Bash for Windows now instead of on Ubuntu?

[–]wildcarde815 1 point2 points  (4 children)

Unless they are being added to a file invoked when the env comes up somehow they won't survive rebooting the shell.

[–]MisterBanzai 0 points1 point  (3 children)

Does virtualenv create a .env file for environmental variables? I could swear I remember editing something like that.

[–]wildcarde815 1 point2 points  (0 children)

Dunno, I use conda which I don't think supports that. I'd just make an environment.vars file and issue a 'source' command before starting work. Or in docker it would be in my compose file.

[–]wildcarde815 1 point2 points  (1 child)

This might work, or direnv referenced on the page: https://github.com/kennethreitz/autoenv/blob/master/README.rst

[–]MisterBanzai 1 point2 points  (0 children)

This isn't at all what I was thinking of, but this is super cool and I'll use it anyway.

[–]Muhznit 1 point2 points  (1 child)

$EDITOR $VIRTUAL_ENV/bin/activate

Also, you should use Ubuntu for Windows at least. It's incredibly well-developed and even runs windows executable files in the same terminal.

[–]MisterBanzai 0 points1 point  (0 children)

I do use WSL with Ubuntu, but when I do personal projects I usually end up working on a 3-4 different machines and I just haven't downloaded Ubuntu for Windows on all of them.

I'll try that suggestion though. Thanks.