pipenv with .env file?
I use pipenv with PIPENV_VENV_IN_PROJECT = 1, so my "activate" file lives at /home/chris/myproj/.venv/bin/activate
So I configure my project to use an activated environment, put in the path above, and things (mostly) work.
I just can't figure out how to get Wing to "source" the ".env" file to set up all my variables.
Anyone have a clue for the clueless?
Comments
It sounds like you've already configured it correctly. Wing should automatically 'source' the environment before debugging or running anything so it should just work. Is there a particular thing that's not working?
in my .env file, i have
If I run this script, I get KeyError:
I'm guessing that sourcing /home/chris/myproj/.venv/bin/activate does not load the .env file. Does it do it if you source that on the command line outside of Wing?
Hmm, also isn't it incorrect and should just be the following?
export DATABASE_URL=postgres://myuser:mypass@localhost:5436/mydb
What you have seems to define an env DATABASE_URL set to "export ..." and of course that doesn't export the env.
Down the rabbit hole we go!
When I'm using the code outside of Wing, I enable the environment using
pipenv shell
. (Not by running theactivate
script directly.)I did find these instructions about Wing + pipenv:
If I do that, Wing appears to set up a new pipenv under ~/.local/share/virtualenvs . (Let me know if you want more details on this.)
Yea, pipenv uses envs stored in that general location and if that's what you're using outside of Wing then I think you also want to use that in Wing and not /home/chris/myproj/.venv/bin/activate. Did you end up installing a venv both with pipenv and some other tool?