我有一个使用flask的深度学习项目。我想将其放入 docker 容器中,但是当我启动容器时,它在 web 中显示此错误:
内部服务器错误 服务器遇到内部错误,无法完成您的请求。服务器超载或应用程序出现错误。
这是容器的日志:
2024-03-18 11:55:14 [2024-03-18 10:55:14,583] ERROR in app: Exception on / [GET]
2024-03-18 11:55:14 Traceback (most recent call last):
2024-03-18 11:55:14 File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1463, in wsgi_app
2024-03-18 11:55:14 response = self.full_dispatch_request()
2024-03-18 11:55:14 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-18 11:55:14 File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 872, in full_dispatch_request
2024-03-18 11:55:14 rv = self.handle_user_exception(e)
2024-03-18 11:55:14 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-18 11:55:14 File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 870, in full_dispatch_request
2024-03-18 11:55:14 rv = self.dispatch_request()
2024-03-18 11:55:14 ^^^^^^^^^^^^^^^^^^^^^^^
2024-03-18 11:55:14 File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 855, in dispatch_request
2024-03-18 11:55:14 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
2024-03-18 11:55:14 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-18 11:55:14 File "/app/process/app.py", line 20, in capture_route
2024-03-18 11:55:14 capture_frame(path_name)
2024-03-18 11:55:14 File "/app/process/f_capture.py", line 4, in capture_frame
2024-03-18 11:55:14 import cv2
2024-03-18 11:55:14 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
2024-03-18 11:55:14 172.17.0.1 - - [18/Mar/2024 10:55:14] "GET / HTTP/1.1" 500
请记住,我有一个包含所有包的
requirements.txt
文件。
我尝试重新安装所有软件包,但没有成功。
解决方案是我将此包添加到requirements.txt文件中:
opencv_python_headless
但现在我有一个相机错误:
[ WARN:[email protected]] global cap_v4l.cpp:997 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
[ERROR:[email protected]] global obsensor_uvc_stream_channel.cpp:159 getStreamChannelGroup Camera index out of range