AttributeError: 'module' object has no attribute 'face' even after installed opencv-contrib-python
运行django服务器时出错。 我通过pip安装了opencv-python和opencv-contrib-python。 仍然得到同样的错误。 有什么建议?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | Performing system checks... Unhandled exception in thread started by Traceback (most recent call last): File"/home/auxouser/.local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File"/home/auxouser/.local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run self.check(display_num_errors=True) File"/home/auxouser/.local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check include_deployment_checks=include_deployment_checks, File"/home/auxouser/.local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks return checks.run_checks(**kwargs) File"/home/auxouser/.local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File"/home/auxouser/.local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config return check_resolver(resolver) File"/home/auxouser/.local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver return check_method() File"/home/auxouser/.local/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check for pattern in self.url_patterns: File"/home/auxouser/.local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__res = instance.__dict__[self.name] = self.func(instance) File"/home/auxouser/.local/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns patterns = getattr(self.urlconf_module,"urlpatterns", self.urlconf_module) File"/home/auxouser/.local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File"/home/auxouser/.local/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, 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/auxouser/Auxo/projects/training-ds/Day-9/Face_Recognition/Face_Recognition/urls.py", line 3, in from MyAPP import views File"/home/auxouser/Auxo/projects/training-ds/Day-9/Face_Recognition/MyAPP/views.py", line 12, in recognizer = cv2.face.LBPHFaceRecognizer_create() AttributeError: 'module' object has no attribute 'face' |
您的项目中可能有一个名为
删除.py文件和生成的.pyc,导入应该再次起作用。