pythonanywhere.com 上没有名为 'rest_framework' 的模块

No module named 'rest_framework' on pythonanywhere.com

我正在尝试在 https://pythonanywhere.com

上托管我的 Django 应用程序

我收到以下错误:

ModuleNotFoundError: No module named 'rest_framework' 

我试过了

pip install djangorestframework

pip3 install djangorestframework

但它仍然显示错误。

我也尝试了 pip freeze 并在列表中找到了 djangorestframework==3.13.1

>>> import rest_framework

也可以正常工作。

我 运行 我在本地的项目以及在新的虚拟环境中的项目,它运行良好。在 pythonanywhere 上安装了相同的 requirements.txt 但仍然出现相同的错误。 这个困扰我好久了!请帮忙

这是我的错误日志文件:

2021-12-22 10:59:23,012: Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 167, in _get_response
    callback, callback_args, callback_kwargs = self.resolve_request(request)
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 290, in resolve_request
    resolver_match = resolver.resolve(request.path_info)
  File "/usr/local/lib/python3.8/dist-packages/django/urls/resolvers.py", line 556, in resolve
    for pattern in self.url_patterns:
  File "/usr/local/lib/python3.8/dist-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.8/dist-packages/django/urls/resolvers.py", line 598, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.8/dist-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.8/dist-packages/django/urls/resolvers.py", line 591, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/shantanu2k21/ytPlaylist/ytPlaylist/urls.py", line 20, in <module>
    path('',include('play.urls')),
  File "/usr/local/lib/python3.8/dist-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/shantanu2k21/ytPlaylist/play/urls.py", line 3, in <module>
    from . import views
  File "/home/shantanu2k21/ytPlaylist/play/views.py", line 13, in <module>
    from rest_framework.decorators import api_view
ModuleNotFoundError: No module named 'rest_framework'

我没有使用虚拟环境,但使用了一个虚拟环境并对其进行了配置。