Python 新手求解:restframework 一直报这个错是怎么回事

一本正经 · 2021年11月24日 · 1328 次阅读

Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_manage.py", line 168, in
utility.execute()
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_manage.py", line 142, in execute
create_command().run_from_argv(self.argv)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_manage.py", line 104, in handle
failures = TestRunner(test_labels, **options)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_runner.py", line 255, in run_tests
extra_tests=extra_tests, **options)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_runner.py", line 156, in run_tests
return super(DjangoTeamcityTestRunner, self).run_tests(test_labels, extra_tests, **kwargs)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/test/runner.py", line 632, in run_tests
self.run_checks()
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/test/runner.py", line 570, in run_checks
call_command('check', verbosity=self.verbosity)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/
init.py", line 148, in call_command
return command.execute(args, **defaults)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/commands/check.py", line 64, in handle
fail_level=getattr(checks, options['fail_level']),
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(
*kwargs)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/urls/resolvers.py", line 399, in check
for pattern in self.url_patterns:
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get
_
res = instance.dict[self.name] = self.func(instance)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/urls/resolvers.py", line 584, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/utils/functional.py", line 80, in get
res = instance.dict[self.name] = self.func(instance)
File "/Users/sherry/apiTest/lib/python3.7/site-packages/django/urls/resolvers.py", line 577, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/init.py", line 127, in import_module
return bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/Users/sherry/Documents/zjy/pythonProject/ah_dashboard_ap_and_gui/ah_dashboard_api/ah_dashboard_api/urls.py", line 18, in
from rest_framework import routers
File "/Users/sherry/apiTest/lib/python3.7/site-packages/rest_framework/routers.py", line 26, in
from rest_framework.schemas.views import SchemaView
File "/Users/sherry/apiTest/lib/python3.7/site-packages/rest_framework/schemas/views.py", line 10, in
from rest_framework.views import APIView
ImportError: cannot import name 'APIView' from 'rest_framework.views' (/Users/sherry/apiTest/lib/python3.7/site-packages/rest_framework/views/
init_.py)

我查了下/Users/sherry/apiTest/lib/python3.7/site-packages/rest_framework/views 下是有 APIViews 的,已经安装了的,但是我百度了下好像也没什么结果,不知道何处着手,安装了却引不到包

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册