Anonymous
Ошибка ImportError для проекта, работающего на Apache: не удалось загрузить DLL при импорте cv2
Сообщение
Anonymous » 03 июл 2024, 11:52
Импорт opencv перед развертыванием работал нормально для моего проекта django, но развертывание в Apache было ошибкой. Позже я написал проект, который использовал opencv только для чтения изображений, но все равно развертывался в Apache с ошибками.
Код: Выделить всё
[Wed Jul 03 15:44:57.683431 2024] [mpm_winnt:notice] [pid 8204:tid 392] AH00455: Apache/2.4.59 (Win64) mod_wsgi/4.9.2 Python/3.8 configured -- resuming normal operations
[Wed Jul 03 15:44:57.683431 2024] [mpm_winnt:notice] [pid 8204:tid 392] AH00456: Apache Lounge VS17 Server built: Apr 4 2024 15:03:17
[Wed Jul 03 15:44:57.683431 2024] [core:notice] [pid 8204:tid 392] AH00094: Command line: 'F:\\bushu\\code\\Apache24\\bin\\httpd.exe -d F:/bushu/code/Apache24 -f F:\\bushu\\code\\Apache24\\conf\\httpd-cv2_text.conf'
[Wed Jul 03 15:44:57.693432 2024] [mpm_winnt:notice] [pid 8204:tid 392] AH00418: Parent: Created child process 3884
[Wed Jul 03 15:44:58.058334 2024] [mpm_winnt:notice] [pid 3884:tid 396] AH00354: Child: Starting 64 worker threads.
[Wed Jul 03 15:45:53.993438 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] mod_wsgi (pid=3884): Exception occurred processing WSGI script 'F:/bushu/code/code/cv2_text/cv2_text/wsgi.py'.
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] Traceback (most recent call last):\r
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\core\\handlers\\exception.py", line 55, in inner\r
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] response = get_response(request)\r
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\core\\handlers\\base.py", line 181, in _get_response\r
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] callback, callback_args, callback_kwargs = self.resolve_request(request)\r
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\core\\handlers\\base.py", line 313, in resolve_request\r
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] resolver_match = resolver.resolve(request.path_info)\r
[Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py", line 663, in resolve\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] for pattern in self.url_patterns:\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\utils\\functional.py", line 57, in __get__\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] res = instance.__dict__[self.name] = self.func(instance)\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py", line 715, in url_patterns\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\utils\\functional.py", line 57, in __get__\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] res = instance.__dict__[self.name] = self.func(instance)\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py", line 708, in urlconf_module\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] return import_module(self.urlconf_name)\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\importlib\\__init__.py", line 127, in import_module\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] return _bootstrap._gcd_import(name[level:], package, level)\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 1014, in _gcd_import\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 991, in _find_and_load\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 975, in _find_and_load_unlocked\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 671, in _load_unlocked\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 783, in exec_module\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 219, in _call_with_frames_removed\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\code\\cv2_text\\cv2_text\\urls.py", line 19, in \r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] from .views import read_iamge\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\code\\cv2_text\\cv2_text\\views.py", line 7, in \r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] import cv2\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\cv2\\__init__.py", line 181, in \r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] bootstrap()\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\cv2\\__init__.py", line 153, in bootstrap\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] native_module = importlib.import_module("cv2")\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\importlib\\__init__.py", line 127, in import_module\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] return _bootstrap._gcd_import(name[level:], package, level)\r
[Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] ImportError: DLL load failed while importing cv2: \xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82\r
Другая платформа, которую я использую для развертывания, — это Windows+django+mod_wsgi.
Подробнее здесь:
https://stackoverflow.com/questions/787 ... le-importi
1719996752
Anonymous
Импорт opencv перед развертыванием работал нормально для моего проекта django, но развертывание в Apache было ошибкой. Позже я написал проект, который использовал opencv только для чтения изображений, но все равно развертывался в Apache с ошибками. [code][Wed Jul 03 15:44:57.683431 2024] [mpm_winnt:notice] [pid 8204:tid 392] AH00455: Apache/2.4.59 (Win64) mod_wsgi/4.9.2 Python/3.8 configured -- resuming normal operations [Wed Jul 03 15:44:57.683431 2024] [mpm_winnt:notice] [pid 8204:tid 392] AH00456: Apache Lounge VS17 Server built: Apr 4 2024 15:03:17 [Wed Jul 03 15:44:57.683431 2024] [core:notice] [pid 8204:tid 392] AH00094: Command line: 'F:\\bushu\\code\\Apache24\\bin\\httpd.exe -d F:/bushu/code/Apache24 -f F:\\bushu\\code\\Apache24\\conf\\httpd-cv2_text.conf' [Wed Jul 03 15:44:57.693432 2024] [mpm_winnt:notice] [pid 8204:tid 392] AH00418: Parent: Created child process 3884 [Wed Jul 03 15:44:58.058334 2024] [mpm_winnt:notice] [pid 3884:tid 396] AH00354: Child: Starting 64 worker threads. [Wed Jul 03 15:45:53.993438 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] mod_wsgi (pid=3884): Exception occurred processing WSGI script 'F:/bushu/code/code/cv2_text/cv2_text/wsgi.py'. [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] Traceback (most recent call last):\r [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\core\\handlers\\exception.py", line 55, in inner\r [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] response = get_response(request)\r [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\core\\handlers\\base.py", line 181, in _get_response\r [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] callback, callback_args, callback_kwargs = self.resolve_request(request)\r [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\core\\handlers\\base.py", line 313, in resolve_request\r [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] resolver_match = resolver.resolve(request.path_info)\r [Wed Jul 03 15:45:54.085121 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py", line 663, in resolve\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] for pattern in self.url_patterns:\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\utils\\functional.py", line 57, in __get__\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] res = instance.__dict__[self.name] = self.func(instance)\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py", line 715, in url_patterns\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\utils\\functional.py", line 57, in __get__\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] res = instance.__dict__[self.name] = self.func(instance)\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py", line 708, in urlconf_module\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] return import_module(self.urlconf_name)\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\importlib\\__init__.py", line 127, in import_module\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] return _bootstrap._gcd_import(name[level:], package, level)\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 1014, in _gcd_import\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 991, in _find_and_load\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 975, in _find_and_load_unlocked\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 671, in _load_unlocked\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 783, in exec_module\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "", line 219, in _call_with_frames_removed\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\code\\cv2_text\\cv2_text\\urls.py", line 19, in \r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] from .views import read_iamge\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\code\\cv2_text\\cv2_text\\views.py", line 7, in \r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] import cv2\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\cv2\\__init__.py", line 181, in \r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] bootstrap()\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\site-packages\\cv2\\__init__.py", line 153, in bootstrap\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] native_module = importlib.import_module("cv2")\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] File "F:\\bushu\\code\\Python38\\lib\\importlib\\__init__.py", line 127, in import_module\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] return _bootstrap._gcd_import(name[level:], package, level)\r [Wed Jul 03 15:45:54.086111 2024] [wsgi:error] [pid 3884:tid 1168] [client 127.0.0.1:57001] ImportError: DLL load failed while importing cv2: \xe6\x89\xbe\xe4\xb8\x8d\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82\r [/code] Другая платформа, которую я использую для развертывания, — это Windows+django+mod_wsgi. Подробнее здесь: [url]https://stackoverflow.com/questions/78700992/importerror-error-for-a-project-running-on-apache-dll-load-failed-while-importi[/url]