Forums

ImportError: No module named 'rest_framework'

I received this message in my log when I try to run my web app, I already install django rest framework in my virtualenv

(sentinel-virtualenv) 16:20 ~ $ pip3.5 install djangorestframework
Looking in links: /usr/share/pip-wheels Requirement already satisfied: djangorestframework in ./.virtualenvs/sentinel-virtualenv/lib/python3.5/site-packages (3.10.3) (sentinel-virtualenv) 16:24 ~ $

and when I try to run --user I received this error: (sentinel-virtualenv) 16:20 ~ $ pip3.5 install --user djangorestframework ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

Have you reloaded your website using the green button on the "Web" page after installing the package? Running Python processes cache whether or not modules exist, so you need to restart them to pick up freshly-installed stuff.

Thank you, the error was change, now I receive this error: Error running WSGI application

2019-12-09 15:47:16,374: django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORK, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

you also posted here.

I received "ImportError: No module named 'rest_framework'" message when I run my wsgi.py via this command: python /var/www/www_rakubaru-posting_com_wsgi.py Here is the error logs: Traceback (most recent call last): File "/var/www/www_rakubaru-posting_com_wsgi.py", line 22, in <module> application = get_wsgi_application() File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application django.setup(set_prefix=False) File "/usr/local/lib/python2.7/dist-packages/django/init.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 94, in create module = import_module(entry) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) ImportError: No module named rest_framework

But this is codes in my wsgi.py

import os import sys project_home = '/home/HirotakaYamamoto/rakubaruproj' if project_home not in sys.path: sys.path.insert(0, project_home) os.environ['DJANGO_SETTINGS_MODULE'] = 'rakubaruproj.settings'

from django.core.wsgi import get_wsgi_application application = get_wsgi_application()

I don't understand what is wrong in the above code. As you see, there is no imported rest_framework in the above code. Can you please help me?

rest_framework is being imported by your Django app, presumably because you have it in the INSTALLED_APPS setting. If you want to use rest_framework install it, if you do not want to use it, remove it from your INSTALLED_APPS.