Run python dlib library on azure app service(在 azure app 服务上运行 python dlib 库)
问题描述
我已经为 Python 3.4 创建了一个 azure 应用服务,并使用此
I have created an azure app service for Python 3.4 and installed pip there using this https://bootstrap.pypa.io/get-pip.py script. Everything works fine except when I try to execute pip install dlib
library the exception occurs:
RuntimeError: CMake must be installed to build the following extensions: dlib
Is there a way to install Cmake
at the machine running this app service?
Here is the solution that worked for me:
Step 0. Create the Flask application in the app.py file for example like this:
from flask import Flask
import dlib
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'This server is running dlib version: {}'.format(dlib.__version__)
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0')
Step 1. Build a Docker file in the same folder with Python, cmake and dlib (I opted for Python 3). Here is the Dockerfile for this:
FROM ubuntu:latest
MAINTAINER Ilya Pukhov "ilya.pukhov@gmail.com"
RUN apt-get update -y
RUN apt-get install -y python3-pip
python3-dev
build-essential
cmake
COPY . /app
WORKDIR /app
RUN pip3 install flask
RUN pip3 install dlib
ENTRYPOINT ["python3"]
CMD ["app.py"]
Here is the readymade file at the Docker Hub https://hub.docker.com/r/garinthengineer/dlib-test-2/
Step 2. Create the Web app on Linux in azure, ensure that the WEBSITES_PORT variable is set to the port number on which your Flask server is listening (by default is 5000) and connect the docker file to it. You may use the Docker Hub link from the previous point. Here is a tutorial for that step https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image#change-web-app-and-redeploy
Profit.
这篇关于在 azure app 服务上运行 python dlib 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 azure app 服务上运行 python dlib 库
基础教程推荐
- 用于分类数据的跳跃记号标签 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 筛选NumPy数组 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01