keisler-au
keisler-au

Reputation: 1

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

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/[email protected]/3.13.2
Executable: /home/linuxbrew/.linuxbrew/Cellar/[email protected]/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?

Upvotes: 0

Views: 19

Answers (1)

keisler-au
keisler-au

Reputation: 1

Issue was a faulty import

from rest_framework.views import APIView, GenericAPIView

It should be

from rest_framework.views import APIView
from rest_framework.generics import GenericAPIView

Upvotes: 0

Related Questions