Django Rest Framework — no module named rest_frame

2020-05-19 03:40发布

I've installed django rest framework using pip install djangorestframework yet I still get this error when I run "python3 manage.py sycndb":

ImportError: No module named 'rest_framework'

I'm using python3, is this my issue?

18条回答
啃猪蹄的小仙女
2楼-- · 2020-05-19 04:08

Yeh for me it was the python version as well ...
much better to use pipenv ...
create a virtual env using using python 3 ...

install pipenv : pip3 install pipenv
create the virtualenv: pipenv --python 3
activate the virtual env: pipenv shell

查看更多
劳资没心,怎么记你
3楼-- · 2020-05-19 04:08

(I would assume that folks using containers know what they're doing, but here's my two cents)

Let's say you setup your project using cookiecutter-django and enabled the docker container support, be sure to update the pip requirements file with djangorestframework==<x.yy.z> (or whichever python dependency you're trying to install) and re-build the docker images (local and production).

查看更多
4楼-- · 2020-05-19 04:12

To install it, do the following:

pip install djangorestframework
pip install markdown     
pip install django-filter

We have to check for a few common mistakes:

  1. check comma at installed list elements

  2. typo errors

查看更多
做个烂人
5楼-- · 2020-05-19 04:12

On Windows, with PowerShell, I had to close and reopen the console and then reactive the virtual environment.

查看更多
我只想做你的唯一
6楼-- · 2020-05-19 04:15

I've faced the same problem, followed these instructions and it worked for me:

  1. python -m pip install --upgrade pip (to upgrade pip)
  2. pip3 install djangorestframework
  3. Added rest_framework as first app:

    INSTALLED_APPS = [
        'rest_framework',
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        #apps
        'apps.endpoints',
    ]
    
查看更多
神经病院院长
7楼-- · 2020-05-19 04:16

rest_framework module

Try pressing the icon given if you are getting the following error:

"ModuleNotFoundError: No module named 'rest_framework'"

It will ask you to import the given package, that is rest_framework and run the code again.

This worked for me and trying to solve that error for a couple of days.

查看更多
登录 后发表回答