Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17011

Enviroment variables in pyenv-virtualenv

$
0
0

I have created a virtual environment with pyenv virtualenv 3.5.9 projectname for developing a django project.

How can I set environment variables for my code to use?

I tried to add the environment variable DATABASE_USER in /Users/developer/.pyenv/versions/projectname/bin/activatelike this:

export DATABASE_USER="dbuser"

When I tried to echo $DATABASE_USER an empty string gets printed.

Tried to install zsh-autoenv

And now I can echo $DATABASE_USER and get the value set in the .autoenv.zsh file.

But I can't seem to get the environment variable to be available to my django code:

If I try to os.getenv('DATABASE_USER', '') in the python shell inside the virtualenv, I get ''

What could be wrong? Is the zsh-autoenv variables just available for the zsh shell and not python manage.py shell ?


Viewing all articles
Browse latest Browse all 17011

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>