Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named rest_framework

i've seen a lot of people having trouble with this here, and i always see them saying other to use pip3 or just pip to install it.

But in my case i've uninstalled it and installed id multiple times both using pip or pip3 and none of them seem to work.

I've added 'rest_framework' to my settings as well and still doesn't seem to work. Help me out please

EDIT
Here is my settings

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'agenda.apps.AgendaConfig',
    'rest_framework',

]

REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
    ]
}

Collecting djangorestframework Downloading djangorestframework-3.7.3-py2.py3-none-any.whl (1.5MB) 100% |████████████████████████████████| 1.5MB 506kB/s Installing collected packages: djangorestframework Successfully installed djangorestframework-3.7.3

Still not working

EDIT 2

> Traceback (most recent call last):   File
> "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py",
> line 226, in wrapper
>     fn(*args, **kwargs)   File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py",
> line 121, in inner_run
>     self.check(display_num_errors=True)   File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 374, in check
>     include_deployment_checks=include_deployment_checks,   File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 361, in _run_checks
>     return checks.run_checks(**kwargs)   File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py",
> line 81, in run_checks
>     new_errors = check(app_configs=app_configs)   File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py",
> line 14, in check_url_config
>     return check_resolver(resolver)   File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py",
> line 24, in check_resolver
>     for pattern in resolver.url_patterns:   File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py",
> line 35, in __get__
>     res = instance.__dict__[self.name] = self.func(instance)   File "/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py",
> line 313, in url_patterns
>     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)   File
> "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py",
> line 35, in __get__
>     res = instance.__dict__[self.name] = self.func(instance)   File "/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py",
> line 306, in urlconf_module
>     return import_module(self.urlconf_name)   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
>     __import__(name)   File "/home/cyro/PycharmProjects/MyClinic/MyClinic/urls.py", line 20, in
> <module>
>     url(r'^agenda/', include('agenda.urls')),   File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py",
> line 50, in include
>     urlconf_module = import_module(urlconf_module)   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
>     __import__(name)   File "/home/cyro/PycharmProjects/MyClinic/agenda/urls.py", line 3, in
> <module>
>     from . import views   File "/home/cyro/PycharmProjects/MyClinic/agenda/views.py", line 8, in
> <module>
>     import rest_framework ImportError: No module named rest_framework
like image 878
Cyro Marcos Schleich Buosi Avatar asked Dec 07 '25 09:12

Cyro Marcos Schleich Buosi


1 Answers

Try using sudo pip install djangorestframework, I've seen other SO questions and it seemed to fix the problem.

like image 169
schrodigerscatcuriosity Avatar answered Dec 08 '25 22:12

schrodigerscatcuriosity



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!