• <small id='HzWX3'></small><noframes id='HzWX3'>

    • <bdo id='HzWX3'></bdo><ul id='HzWX3'></ul>
      <legend id='HzWX3'><style id='HzWX3'><dir id='HzWX3'><q id='HzWX3'></q></dir></style></legend>

        <tfoot id='HzWX3'></tfoot>

      1. <i id='HzWX3'><tr id='HzWX3'><dt id='HzWX3'><q id='HzWX3'><span id='HzWX3'><b id='HzWX3'><form id='HzWX3'><ins id='HzWX3'></ins><ul id='HzWX3'></ul><sub id='HzWX3'></sub></form><legend id='HzWX3'></legend><bdo id='HzWX3'><pre id='HzWX3'><center id='HzWX3'></center></pre></bdo></b><th id='HzWX3'></th></span></q></dt></tr></i><div id='HzWX3'><tfoot id='HzWX3'></tfoot><dl id='HzWX3'><fieldset id='HzWX3'></fieldset></dl></div>
      2. 为什么 azure app service django deploy 总是失败?

        时间:2023-10-20

          • <bdo id='G4Wl7'></bdo><ul id='G4Wl7'></ul>
              <legend id='G4Wl7'><style id='G4Wl7'><dir id='G4Wl7'><q id='G4Wl7'></q></dir></style></legend>
                <tbody id='G4Wl7'></tbody>

                <tfoot id='G4Wl7'></tfoot>
              • <i id='G4Wl7'><tr id='G4Wl7'><dt id='G4Wl7'><q id='G4Wl7'><span id='G4Wl7'><b id='G4Wl7'><form id='G4Wl7'><ins id='G4Wl7'></ins><ul id='G4Wl7'></ul><sub id='G4Wl7'></sub></form><legend id='G4Wl7'></legend><bdo id='G4Wl7'><pre id='G4Wl7'><center id='G4Wl7'></center></pre></bdo></b><th id='G4Wl7'></th></span></q></dt></tr></i><div id='G4Wl7'><tfoot id='G4Wl7'></tfoot><dl id='G4Wl7'><fieldset id='G4Wl7'></fieldset></dl></div>
                1. <small id='G4Wl7'></small><noframes id='G4Wl7'>

                  本文介绍了为什么 azure app service django deploy 总是失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  已经 1 个月了,我仍然无法弄清楚我或 azure 中的应用服务出了什么问题.

                  It's been 1 month and I still can't figure out what's wrong with me or app service in azure.

                  我使用了 python 2.7 和 django 1.11.3,带有这个 requirements.txt

                  I used python 2.7 and django 1.11.3, with this requirements.txt

                  beautifulsoup4==4.6.0证书==2017.7.27.1chardet==3.0.4Django==1.11.5idna==2.6olefile==0.44枕头==4.2.1pytz==2017.2请求==2.18.4urllib3==1.22

                  beautifulsoup4==4.6.0 certifi==2017.7.27.1 chardet==3.0.4 Django==1.11.5 idna==2.6 olefile==0.44 Pillow==4.2.1 pytz==2017.2 requests==2.18.4 urllib3==1.22

                  当我使用本地 Git 存储库部署到 Azure Web 服务(Python2.7,Windows)时,它似乎没有安装要求.

                  When I deploy with Local Git Repository to Azure Web Service(Python2.7, Windows) it doesn't seems to install the requirements.

                  我尝试了 wheel 但它没有做任何事情,并且通过 scm powershell 我未能安装任何要求,例如:

                  I tried wheel but it doesn't do anything, and via scm powershell I failed to install any of the requirements, example:

                  Python -m pip install django

                  Python -m pip install django

                  它没有给我权限错误.

                  推荐答案

                  在 Azure WebApps 上,Python 默认安装在 D:Python27 路径,用户无任何写入权限像命令 pip install <packages> 这样的操作将 Python 包安装到 libs,除了路径 D:home 下.

                  On Azure WebApps, Python is installed default at the path D:Python27 which has no permission for users to do any write operations like command pip install <packages> to install Python packages to libs, besides under the path D:home.

                  所以首先你需要通过 Kudu 站点扩展在 D:home 路径下安装一个新的 Python 运行时,如下图.

                  So first you need to install a new Python runtime at the path D:home via Kudu site extensions, as the figure below.

                  然后就可以在D:home下看到你有写操作权限的Python目录了.

                  Then, you can see the Python directory under D:home which you have the write operation permission.

                  如需安装所需的 Python 包,请执行以下命令安装 pip 工具.

                  For installing Python packages you want, do the commands as below to install pip tool.

                  D:home> cd Python27
                  D:homePython27> curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
                    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                   Dload  Upload   Total   Spent    Left  Speed
                  
                  100 1558k  100 1558k    0     0  5069k      0 --:--:-- --:--:-- --:--:-- 6546k
                  D:homePython27> python get-pip.py
                  Requirement already up-to-date: pip in d:homepython27libsite-packages
                  Collecting wheel
                    Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
                  Installing collected packages: wheel
                  Successfully installed wheel-0.30.0
                  

                  接下来,可以通过python -m pip install <package-name>安装这些包,比如python -m pip install django==1.11.5 如下.

                  The next, you can install these packages via python -m pip install <package-name>, such as python -m pip install django==1.11.5 as below.

                  D:homePython27> python -m pip install django==1.11.5
                  Collecting django==1.11.5
                    Downloading Django-1.11.5-py2.py3-none-any.whl (6.9MB)
                  Collecting pytz (from django==1.11.5)
                    Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
                  Installing collected packages: pytz, django
                  

                  正如官方文档所说,对于 Troubleshooting - Package Installation, 如下,对于 package Pillow 需要编译 C 代码.

                  As the offical document said, for Troubleshooting - Package Installation, as below, like for package Pillow need compiler for C code.

                  疑难解答 - 软件包安装

                  Troubleshooting - Package Installation

                  在 Azure 上运行时,某些包可能无法使用 pip 安装.可能只是因为该包在 Python 包索引中不可用.可能需要编译器(在 Azure 应用服务中运行 Web 应用的机器上没有编译器).

                  Some packages may not install using pip when run on Azure. It may simply be that the package is not available on the Python Package Index. It could be that a compiler is required (a compiler is not available on the machine running the web app in Azure App Service).

                  你需要从这里通过命令curl -o <轮子文件名><wheel-file-url> 在 Kudu CMD 上,并通过命令 python -m pip install <wheel-file-name> 安装它们.

                  You need to download package wheel files from here via command curl -o <wheel-file-name> <wheel-file-url> on Kudu CMD, and install them via command python -m pip install <wheel-file-name>.

                  安装完所有包后,你可以上传你的django webapp到D:homesitewwwroot,这个路径下的文件结构和官方的sample 包括这些目录 app, <your-django-project-name> 由 PTVS 在 VS 2017 上创建.

                  After installed all packages, you can upload your django webapp to D:homesitewwwroot, the file structure under this path looks like the offical sample that includes these directories app, <your-django-project-name> created by PTVS on VS 2017.

                  最后,请配置您的 web.config 文件以使您的应用正常运行.

                  Finally, please configure your web.config file to make your app works.

                  <configuration>
                    <appSettings>
                      <add key="WSGI_HANDLER" value="<your-django-project-name>.wsgi.application"/>
                      <add key="PYTHONPATH" value="D:homesitewwwroot"/>
                      <add key="WSGI_LOG" value="D:homeLogFileswfastcgi.log"/>
                    </appSettings>
                    <system.webServer>
                      <handlers>
                        <add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:homePython27python.exe|D:homePython27wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
                      </handlers>
                      <rewrite>
                        <rules>
                          <rule name="Static Files" stopProcessing="true">
                            <conditions>
                              <add input="true" pattern="false" />
                            </conditions>
                          </rule>
                          <rule name="Configure Python" stopProcessing="true">
                            <match url="(.*)" ignoreCase="false" />
                            <conditions>
                              <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
                            </conditions>
                            <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
                          </rule>
                        </rules>
                      </rewrite>
                    </system.webServer>
                  </configuration>
                  

                  希望对您有所帮助.有任何问题,请随时告诉我.

                  Hope it helps. Any concern, please feel free to let me know.

                  这篇关于为什么 azure app service django deploy 总是失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 sqlalchemy 中使用子查询添加行? 下一篇:Django 频道和天蓝色

                  相关文章

                    <bdo id='KbXrK'></bdo><ul id='KbXrK'></ul>

                  1. <tfoot id='KbXrK'></tfoot>

                    <small id='KbXrK'></small><noframes id='KbXrK'>

                    <i id='KbXrK'><tr id='KbXrK'><dt id='KbXrK'><q id='KbXrK'><span id='KbXrK'><b id='KbXrK'><form id='KbXrK'><ins id='KbXrK'></ins><ul id='KbXrK'></ul><sub id='KbXrK'></sub></form><legend id='KbXrK'></legend><bdo id='KbXrK'><pre id='KbXrK'><center id='KbXrK'></center></pre></bdo></b><th id='KbXrK'></th></span></q></dt></tr></i><div id='KbXrK'><tfoot id='KbXrK'></tfoot><dl id='KbXrK'><fieldset id='KbXrK'></fieldset></dl></div>
                    <legend id='KbXrK'><style id='KbXrK'><dir id='KbXrK'><q id='KbXrK'></q></dir></style></legend>