[Python] cant print api key from env even after using os.getenv

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    I wanted to see if I had any issues with my setup of env.

    I used python in Vscode

    Here is my code:

    import os
    import requests

    from dotenv import load_dotenv, dotenv_values
    load_dotenv()

    api_key = os.getenv("myKey")

    print('hi')
    print(api_key)


    But it is constantly returning "None" for my API key.

    Notes: The python file and .env file are in the same directory Everything is installed properly No error messages I also tried only importing load_dotenv instead of oing both dotenv_values as well

    Checking directory Pip install and uninstall needed modules Switching python interpreters, although I run into errors when using python 3.12.1 instead of 3.11.0, both are 64 bit.

    Continue reading...

Compartilhe esta Página