1."ImportError: cannot import name '_imaging' from 'PIL' (/code/PIL/__init__.py)"
出现场景:本地调试和云部署的过程中出现该问题
问题原因:Pillow和dlib和face-recognition的版本冲突。
解决方法:(本地调试可以借鉴,云部署无法解决)重新安装pillow或其他报错的软件,使版本一致。强制安装依赖的命令行:
pip3 install --upgrade --force-reinstall pillow -t . -i https://pypi.mirrors.ustc.edu.cn/simple --python-version 3.9.13 --no-deps
2.'ModuleNotFoundError'>, ModuleNotFoundError("No module named '_dlib_pybind11'")
出现场景:本地调试和云部署的过程中出现该问题
问题原因:dlib版本错误
解决方法:(本地调试可以借鉴,云部署无法解决)安装指定版本dlib
pip3 install --upgrade --force-reinstall dilb -t . -i https://pypi.mirrors.ustc.edu.cn/simple --python-version 3.9.13 --no-deps
3.'Unable to locate package cmake'
出现场景:制作镜像
问题原因:dlib的安装底层需要gcc和g++de解析
解决方法:在dockerfile中run
apt-get update
4.'CMAKE_CXX_COMPLILER COULD not BE FOUND'
出现场景:制作镜像
问题原因:face-recognition依赖的安装需要dlib,dlib的安装需要gcc、g++的解析,需要安装cmake
解决方法:在dockerfile中run
apt-get install -y gcc
apt-get install -y g++
5.CMake Error: 'CMAKE_C_COMPILER not set, after EnableLanguage' &&' CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage'
出现场景:制作镜像
问题原因:cmake需要下载和安装到镜像中
解决方法:在dockerfile中run
RUN apt-get -y install cmake protobuf-compiler
6.'error: subprocess-exited-with-error'
出现场景:制作镜像
问题原因:cmake需要下载和安装到镜像中
解决方法:没有找到特殊的解决方法,在上面三个问题解决后没有复现
7.'ERROR: CMake must be installed to build dlib'
同上
8. 'CMake Error: CMake was unable to find a build program corresponding to "Unix'
同上
Dockerfile
FROM python:3.9.7-slim
WORKDIR /usr/src/app
COPY requirements.txt ./
#RUN sudo apt install make准备cmake环境
RUN apt-get update
RUN apt-get install -y gcc
RUN apt-get install -y g++
RUN apt-get -y install cmake protobuf-compiler
## 安装Face Recognition和OpeCV,指定国内镜像源,这样下载速度快些
RUN pip3 install face_recognition -i https://pypi.douban.com/simple/
RUN pip3 install opencv-python -i https://pypi.douban.com/simple/
# 安装requirements里的其他安装包
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
#强制匹配依赖版本
RUN pip3 install --upgrade --force-reinstall pillow --target . -i https://pypi.mirrors.ustc.edu.cn/simple --python-version 3.9 --no-deps
RUN pip3 install --upgrade --force-reinstall numpy --target . -i https://pypi.mirrors.ustc.edu.cn/simple --python-version 3.9 --no-deps
COPY . .
CMD [ "python", "-u", "./app.py" ]