[Python] VSCode terminal cannot import environment variables

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

  1. Stack

    Stack Membro Participativo

    I am using Ubuntu + VSCode + Django + venv for developing and I have a trouble while trying to launch django project. I've done this command one by one in terminal:

    source .venv/bin/activate
    cd my_project
    python manage.py makemigrations


    but last one returns this:

    ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS').split(' ')
    AttributeError: 'NoneType' object has no attribute 'split'


    I think getenv returns None, but I have ALLOWED_HOSTS in my .env file. I don't wanna use python_dotenv. What can I do to solve this problem?

    I've tried to install DotENV extension for VSCode, change user settings in vscode, but nothing worked

    Continue reading...

Compartilhe esta Página