Azure Webapp内没有pip或python模块 [英] No pip or python module inside azure webapp

查看:48
本文介绍了Azure Webapp内没有pip或python模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用python作为Web应用程序的后端将Web应用程序部署为Azure,但是无论何时我尝试从本地git进行部署,它都能正常工作,但是应用程序失败.

I have been trying to deploy a web application to azure using python as the backend for the web application however anytime i try to deploy from local git it works correctly however the application fails.

尝试直接从Azure上的应用程序控制台运行脚本后:

After trying to run the script directly from the application console on azure :

Python hostingstart.py

导致错误:

No module Flask found

意识到这一点之后,我尝试在命令行中运行pip,看来azure已安装了python 3.6.6版,这很好,但是我无法直接从命令行调用pip.

After realising this, i tried to run pip in the command-line and it seems azure has python version 3.6.6 installed which is fine, but i cannot call pip directly from the commandline.

但是当我从本地执行git push时,它会正确部署":

However it does "deploy correctly" when i do a git push from local:

remote: Requirement already satisfied: click==6.7 in d:\home\site\wwwroot\env\lib\site-packages (from -r requirements.txt (line 1)) (6.7)
remote: Requirement already satisfied: Flask==1.0.2 in d:\home\site\wwwroot\env\lib\site-packages (from -r requirements.txt (line 2)) (1.0.2)
remote: Requirement already satisfied: itsdangerous==0.24 in d:\home\site\wwwroot\env\lib\site-packages (from -r requirements.txt (line 3)) (0.24)
remote: Requirement already satisfied: Jinja2==2.10 in d:\home\site\wwwroot\env\lib\site-packages (from -r requirements.txt (line 4)) (2.10)
remote: Requirement already satisfied: MarkupSafe==1.0 in d:\home\site\wwwroot\env\lib\site-packages (from -r requirements.txt (line 5)) (1.0)
remote: Requirement already satisfied: Werkzeug==0.14.1 in d:\home\site\wwwroot\env\lib\site-packages (from -r requirements.txt (line 6)) (0.14.1)
remote: You are using pip version 10.0.1, however version 19.0.3 is available.
remote: You should consider upgrading via the 'python -m pip install --upgrade pip' command.
remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.

似乎我缺少一个步骤,因为我在requirements.txt中提供了我的要求,而azure似乎建议将它们作为部署的一部分进行安装...尽管不确定如何在pip中安装pip通过Web控制台访问计算机....任何人都可以解释发生了什么事吗?

It seems like there is a step I am missing as I have provided my requirements in requirements.txt and azure seems to suggest they are being installed as part of the deployment...although im unsure how as pip isnt installed in the machine im accessing via the web console....can anyone explain what is going on?

其他可能有用的注释:

我通过azure Web ui而不是通过az webapp部署应用程序,因为我不想将其部署到新组中的新linux容器中,我希望资源位于特定的预定义组中(而不是请确保这是否有意义,因为尽管没有解决依赖关系,该Web应用程序仍在运行中.

I deploy the application through the azure web ui not via the az webapp up as i did not want to deploy into a new linux container in a new group, i wanted the resource to be in a specific pre-defined group (not sure if this is relevant as the web app is infact up despite not resolving the dependencies).

默认部署的Web应用程序可以很好地显示:该网站运行的是Python 3.6.6.

The default deployed web app works fine showing : This web site is running Python 3.6.6.

推荐答案

我看到您正在将Flask应用程序部署到Windows版Azure WebApp上的IIS上,而不是部署到Linux版Azure WebApp的容器上,但是您遵循了有关的官方教程Linux部署.

I see you were deploying a Flask App to IIS on Azure WebApp for Windows, not to a container of Azure WebApp for Linux, but you followed the offical tutorial for Linux deployment.

因此,您可以按照以下针对这些SO线程的回答来进行部署.

So you can try to follow my answers for these SO threads as below to deploy it.

  1. 托管Flask(Python)应用会引发CGI错误
  2. 在Azure上发布Flask Web应用
  3. 发布使用python脚本的MVC应用

步骤大致如下:

  1. 上传或git推送您的应用.
  2. 通过Kudu在您的Web应用中安装Python扩展.
  3. 要为您之前安装的Python扩展安装 pip .
  4. 使用 pip 安装这些必需的依赖项,例如 flask requirements.txt 中定义的其他依赖项.
  5. 创建一个 web.config 文件,并将其配置为IIS以启动flask应用程序.
  1. Upload or git push your app.
  2. Install a Python extension in your webapp via Kudu.
  3. To install pip for the Python extension you installed before.
  4. Use pip to install these necessary dependencies, like flask or others defined in requirements.txt.
  5. Create a web.config file and configure it for IIS to start up your flask app.

这篇关于Azure Webapp内没有pip或python模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆