Django Rest Framework — no module named rest_framework

后端 未结 21 794
夕颜
夕颜 2021-02-01 00:23

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

相关标签:
21条回答
  • 2021-02-01 00:47

    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

    0 讨论(0)
  • 2021-02-01 00:48

    When using a virtual environment like virtualenvwithout having django-rest-framework installed globally you might as well have the error. The solution would be:

    • activate the environment first with {{your environment name}}/bin/activate for Linux or {{your environment name}}/Scripts/activate for Windows

    • and then run the command again.

    0 讨论(0)
  • 2021-02-01 00:49

    try this if you are using JWT pip install djangorestframework-jwt

    0 讨论(0)
  • 2021-02-01 00:49

    In my case, my problem was different. I was creating in my bash_profile an alias like:

    alias python=/usr/local/bin/python3
    

    And even if I activate my environment, when I ran the command, the python interpreter accessed was from the system and not from my environment.

    I just removed the alias from bash_profile and it worked fine.

    0 讨论(0)
  • 2021-02-01 00:51

    Also, check for the possibility of a tiny typo:

    It's rest_framework with an underscore (_) in between!

    Took me a while to figure out that I was using a dash instead...

    0 讨论(0)
  • 2021-02-01 00:51

    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.

    0 讨论(0)
提交回复
热议问题