简体   繁体   English

Azure 部署未安装 requirements.txt 中列出的 Python 包

[英]Azure deployment not installing Python packages listed in requirements.txt

This is my first experience deploying a Flask web app to Azure.这是我第一次将 Flask Web 应用程序部署到 Azure。 I followed this tutorial .我跟着这个教程

The default demo app they have works fine for me.他们拥有的默认演示应用程序对我来说很好用。

Afterwards, I pushed my Flask app via git.之后,我通过 git 推送了我的 Flask 应用程序。 The log shows deployment was successful.日志显示部署成功。 However, when I browse the hosted app via link provided in "Application Properties", I get a 500 error as follows:但是,当我通过“应用程序属性”中提供的链接浏览托管应用程序时,出现 500 错误,如下所示:

The page cannot be displayed because an internal server error has occurred.由于发生内部服务器错误,无法显示该页面。

Most likely causes: IIS received the request;最可能的原因:IIS 收到请求; however, an internal error occurred during the processing of the request.但是,在处理请求期间发生了内部错误。 The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.此错误的根本原因取决于处理请求的模块以及发生此错误时工作进程中发生的情况。 IIS was not able to access the web.config file for the Web site or application. IIS 无法访问网站或应用程序的 web.config 文件。 This can occur if the NTFS permissions are set incorrectly.如果 NTFS 权限设置不正确,就会发生这种情况。 IIS was not able to process configuration for the Web site or application. IIS 无法处理网站或应用程序的配置。 The authenticated user does not have permission to use this DLL.经过身份验证的用户无权使用此 DLL。 The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.请求映射到托管处理程序,但未安装 .NET 扩展功能。

The only off-base thing I can see by browsing the wwwroot via KUDU is that none of the packages I have installed in my local virtual environment are installed on Azure despite the existence of the "requirements.txt" file in wwwroot.通过 KUDU 浏览 wwwroot,我能看到的唯一不符合基础的事情是,尽管 wwwroot 中存在“requirements.txt”文件,但我在本地虚拟环境中安装的任何包都没有安装在 Azure 上。

My understanding is that Azure would pip install any non existent package that it finds in the requirements.txt upon GIT successful push.我的理解是,Azure 会在 GIT 成功推送后安装它在 requirements.txt 中找到的任何不存在的包。 But it doesn't seem to be happening for me.但这似乎不会发生在我身上。

Am I doing something wrong and the missing packages is just a symptom or could it be the cause the issue?我做错了什么,丢失的包裹只是一种症状还是可能是问题的原因?

Notes:笔记:

  • My Flask app works fine locally (linux) and on a 3rd party VPS我的 Flask 应用程序在本地 (linux) 和 3rd 方 VPS 上运行良好

  • I redeployed several times starting from scratch to no avail (I use local GIT method)我从头开始重新部署了几次都没有用(我用的是本地GIT方法)

  • I cloned the Azure Flask demo app locally, changed just the app folder and pushed back to Azure, yet no success.我在本地克隆了 Azure Flask 演示应用程序,只更改了应用程序文件夹并推送回 Azure,但没有成功。

  • Azure is set to Python 2.7 same as my virtual env locally Azure 设置为 Python 2.7,与我在本地的虚拟环境相同

  • As suggested in the tutorial linked above, I deleted the "env" folder and redeployed to trick Azure to reinstall the virtual env.正如上面链接的教程中所建议的那样,我删除了“env”文件夹并重新部署以欺骗 Azure 重新安装虚拟环境。 It did but with its own default packages not the one in my requirements.txt.它确实使用了它自己的默认包,而不是我的 requirements.txt 中的包。

My requirements.txt has the following:我的 requirements.txt 有以下内容:

bcrypt==3.1.0 cffi==1.7.0 click==6.6 Flask==0.11.1 Flask-Bcrypt==0.7.1 Flask-Login==0.3.2 Flask-SQLAlchemy==2.1 Flask-WTF==0.12 itsdangerous==0.24 Jinja2==2.8 MarkupSafe==0.23 pycparser==2.14 PyMySQL==0.7.7 python-http-client==1.2.3 six==1.10.0 smtpapi==0.3.1 SQLAlchemy==1.0.14 Werkzeug==0.11.10 WTForms==2.1 bcrypt==3.1.0 cffi==1.7.0 click==6.6 Flask==0.11.1 Flask-Bcrypt==0.7.1 Flask-Login==0.3.2 Flask-SQLAlchemy==2.1 Flask-WTF==0.12 itsdangerous==0.24 Jinja2==2.8 MarkupSafe==0.23 pycparser==2.14 PyMySQL==0.7.7 python-http-client==1.2.3 Six==1.10.0 smtpapi==0.3.1 SQLAlchemy==1.0.14 Werkzeug==0.11.10 WTForms==2.1

As Azure Web Apps will run a deploy.cmd script as the deployment task to control which commands or tasks will be run during the deployment.由于 Azure Web Apps 将运行deploy.cmd脚本作为部署任务,以控制在部署期间将运行哪些命令或任务。

You can use the command of Azure-CLI azure site deploymentscript --python to get the python applications' deployment task script.您可以使用 Azure-CLI azure site deploymentscript --python命令获取 python 应用程序的部署任务脚本。

And you can find the following script in this deploy.cmd sciprt:您可以在此deploy.cmd sciprt 中找到以下脚本:

IF NOT EXIST "%DEPLOYMENT_TARGET%\requirements.txt" goto postPython
IF EXIST "%DEPLOYMENT_TARGET%\.skipPythonDeployment" goto postPython

echo Detected requirements.txt.  You can skip Python specific steps with a .skipPythonDeployment file.

So the .skipPythonDeployment will skip all the following steps in deployment task, including creating virtual environment.因此.skipPythonDeployment将跳过部署任务中的所有以下步骤,包括创建虚拟环境。

You can try to remove .skipPythonDeployment from your application, and try again.您可以尝试从应用程序中删除.skipPythonDeployment ,然后重试。

Additionally, please refer to https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script for more info.此外,请参阅https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jedi python 在从 requirements.txt 安装软件包时未安装 - Jedi python is not installing while installing packages from requirements.txt 通过从 python 文件中引用来安装 requirements.txt 中的软件包 - Installing packages present in requirements.txt by referencing it from a python file 使用 requirements.txt 文件安装 python 包 - Installing python packages using requirements.txt file 从 python 项目的 requirements.txt 安装 R 包 - Installing R packages from python project's requirements.txt 从 python 3.9 中的 requirements.txt 安装软件包时出错 - Error while Installing Packages from requirements.txt in python 3.9 从requirements.txt安装选定的软件包 - Installing selected packages from requirements.txt 如何检查requirements.txt文件中列出的所有包是否在Python项目中使用 - How to check if all packages listed in requirements.txt file are used in Python project 使用 requirements.txt 为 Azure function 安装软件包失败,没有信息 - Installing packages using requirements.txt for Azure function fails without info 通过 azure web 服务部署的 requirements.txt 安装 Torch 时出错 - Error when installing torch through requirements.txt for azure web service deployment Azure function部署单个Python脚本和Azure函数中requirements.txt的安装过程 - Azure function deployment of single Python script and process of installation of requirements.txt in Azure Functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM