[Python] Why I can't access my environment variable from .env file in vscode python?

Discussão em 'Python' iniciado por Stack, Julho 31, 2025.

  1. Stack

    Stack Membro Participativo

    What I am trying to do? I am trying to access my environment variable from the .env file and print its value in the terminal.

    What is the issue? When I run the script in the terminal I keep getting the error none

    Some more info:

    I am using Windows 10

    The version of dotenv is 0.20.0

    I downloaded it using python -m pip install python-dotenv

    The code

    .env file - export PRIVATE_KEY = 0xc3c4e4fe27d8e6b06710e713878e4488c034ce346a578fdfa78bb3d335130eec

    The Python file -

    from dotenv import load_dotenv

    import os

    load_dotenv()

    print(os.getenv("PRIVATE_KEY"))

    Continue reading...

Compartilhe esta Página