Maintain different environments (Pipenv)

Hi , so I have started development with python and I am currently using Pipenv for managing my dependencies of my project. Now I have to create multiple environments for staging , development and production. I integrated python-dotenv but I am having a few issues with that. I want to know if there is a way to load the env file and then inject those environment variables in the process. I want to manage multiple versions. I created a script and tried to load custom env files on the basis of ENV environment variable

dev = “export ENV=‘DEV’ && python3.9 ./init.py”

but when I try to run this script I get an error

“the command export (from dev) could not be found within PATH.”

If anyone knows a clean way to inject environment variables from the script itself in Pipenv

Try using the env command instead

[scripts]
dev = "env ENV=DEV python3.9 ./__init__.py"
2 Likes

The script entry is not a bash repl, so you can’t do bash syntax in it. env is a good solution. Or you can wrap the thing inside bash -c.

1 Like

thanks dude , it worked, I appreciate your help

Thank you , I am learning a lot of things through this forum , I appreciate your help :slight_smile: