Skip to main content

Import environment variables from your .env file or run as command line tool; PyDotEnv Cli.

Project description


Import environment variables from your .env file or run as command line tool; PyDotEnv Cli.

  • Python 2 & 3
  • Command line tool

How to use

pip install pydotenvs


git clone
cd pyenv
pip install --editable .

Now import into any python project you have

from pydotenvs import load_env




envObj = load_env_object()

That's it!


Run this to see a working example

python example/


You can load your local .env file as a StringIO object. By default you are responsible for closing the StringIO object. Though, There is an option to auto close upon program termination.

from pydotenvs import load_env
stringObj = load_env(stringIO = True, auto_close = True)
contents = stringObj.getvalue()

Command Line Tool - CLI

You can use PyEnv as a command line tool. All the same features apply. It would be common to use the client tool for the Dictionary & StringIO features of PyEnv.

You can run a command that requires your local environment variables with PyEnv command line tool. Your variables will only exist in that one instance.

 pyenv --command 'echo $MY_VARIABLE'
Usage: pyenv [OPTIONS]

  -f, --envpath PATH      Location of .env file, defaults to .env in current
                          working directory  [required]
  -c, --command TEXT      Run a command that requires local enviornment
                          variables for one instance
  -l, --loadobj BOOLEAN   Load .env file as object instead of environment
  -s, --stringio BOOLEAN  Load .env file as StringIO object instead of
                          environment variable
  -v, --verbose BOOLEAN   Verbose
  --version               Show the version and exit.
  --help                  Show this message and exit.


  • October 2020 - Minor version update
    • Any message that should/shall be printed (unrelated to an error) will be controlled by the boolean value of verbose.
    • Cleaned the CLI code, slightly

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pydotenvs, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size pydotenvs-0.1.4-py3-none-any.whl (5.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pydotenvs-0.1.4.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page