Django Rest Framework -- no module named rest_framework

Solution 1:

You need to install django rest framework using pip3 (pip for python 3):

pip3 install djangorestframework

Instructions on how to install pip3 can be found here

Solution 2:

if you forget ,,this will happen,it's weird

wrong example: need a ,

INSTALLED_APPS = [
'rest_framework'
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

Solution 3:

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... 😅

Solution 4:

If you're using some sort of virtual environment do this!

  1. Exit from your virtual environment.

  2. Activate your virtual environment.

After you've done this you can try running your command again and this time it probably won't have any ImportErrors.