[Python] How do I change the Base path and executables for poetry env

Discussão em 'Python' iniciado por Stack, Março 2, 2025.

  1. Stack

    Stack Membro Participativo

    When I run
    poetry run python manage.py runserver
    in my django backend I get this error
    ImportError: cannot import name 'GenericAPIView' from 'rest_framework.views'

    I think it is related to my poetry env, I think poetry env is using something different to my VS Code interpreter.

    This is the details of my poetry env

    poetry env info

    Virtualenv
    Python: 3.13.2
    Implementation: CPython
    Path: /home/josh/.cache/pypoetry/virtualenvs/backend-0Uga-fli-py3.13
    Executable: /home/josh/.cache/pypoetry/virtualenvs/backend-0Uga-fli-py3.13/bin/python
    Valid: True

    Base
    Platform: linux
    OS: posix
    Python: 3.13.2
    Path: /home/linuxbrew/.linuxbrew/Cellar/python@3.13/3.13.2
    Executable: /home/linuxbrew/.linuxbrew/Cellar/python@3.13/3.13.2/bin/python3.13


    The details of my poetry env in an adjacent project is

    poetry env info

    Virtualenv
    Python: 3.13.2
    Implementation: CPython
    Path: /home/josh/.cache/pypoetry/virtualenvs/backend-K_DTF70p-py3.13
    Executable: /home/josh/.cache/pypoetry/virtualenvs/backend-K_DTF70p-py3.13/bin/python
    Valid: True

    Base
    Platform: linux
    OS: posix
    Python: 3.13.2
    Path: /home/linuxbrew/.linuxbrew
    Executable: /home/linuxbrew/.linuxbrew/bin/python3.13


    Running
    poetry run python manage.py runserver

    in this project works, and the Base path and executable looks more typical

    What is Base, how does it get set, and ultimately how do I change it?

    Continue reading...

Compartilhe esta Página