MacOS|Python3|Docker制作带face-recognition镜像踩的坑

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" ]

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值