gpt4 book ai didi

python - requirements.txt 依赖项未与 Azure Web 应用程序上的代码一起部署

转载 作者:行者123 更新时间:2023-12-03 00:22:10 25 4
gpt4 key购买 nike

我一直在开发一个 Django 网站,并在一个基本的 Azure Web 应用程序上对其进行了测试,现在它几乎完成了,我已经启动了一个生产实例,但我没有运气部署到它。我使用的部署脚本与之前基本相同,部署日志输出看起来相同,但启动时失败,因为尚未安装 Django,而且也没有满足任何要求。

这是我的部署脚本

# Python to Linux Web App on Azure
# Build your Python project and deploy it to Azure as a Linux Web App.
# Change python version to one thats appropriate for your application.
# https://learn.microsoft.com/azure/devops/pipelines/languages/python

trigger:
- Release-0.1

variables:
# Azure Resource Manager connection created during pipeline creation
azureServiceConnectionId: ''

# Web app name
webAppName: ''

# Agent VM image name
vmImageName: 'ubuntu-latest'

# Environment name
environmentName: ''

# Project root folder. Point to the folder containing manage.py file.
projectRoot: $(System.DefaultWorkingDirectory)

# Python version: 3.8
pythonVersion: '3.8'

stages:
- stage: Build
displayName: Build stage
jobs:
- job: BuildJob
pool:
vmImage: $(vmImageName)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python $(pythonVersion)'

- script: |
python -m venv antenv
source antenv/bin/activate
python -m pip install --upgrade pip
pip3 install setup
pip3 install -r requirements.txt
workingDirectory: $(projectRoot)
displayName: "Install requirements"

- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(projectRoot)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true

- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
displayName: 'Upload package'
artifact: drop

- stage: Deploy
displayName: 'Deploy Web App'
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeploymentJob
pool:
vmImage: $(vmImageName)
environment: $(environmentName)
strategy:
runOnce:
deploy:
steps:

- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python version'

- task: AzureWebApp@1
displayName: 'Deploy Azure Web App : '
inputs:
deployToSlotOrASE: true
azureSubscription: $(azureServiceConnectionId)
appName: $(webAppName)
slotName: 'staging'
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip

这是构建日志

 ##[section]Starting: BuildJob
##[section]Starting: Initialize job
Agent name: 'Hosted Agent'
Agent machine name: 'fv-az216-917'
Current agent version: '2.182.1'
##[group]Operating System
Ubuntu
20.04.2
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-20.04
Version: 20210219.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20210219.1/images/linux/Ubuntu2004-README.md
##[endgroup]
Current image version: '20210219.1'
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Downloading task: UsePythonVersion (0.181.0)
Downloading task: CmdLine (2.182.0)
Downloading task: ArchiveFiles (2.179.0)
Downloading task: PublishPipelineArtifact (0.140.1)
Checking job knob settings.
Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY}
Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG}
Finished checking job knob settings.
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Checkout <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="397d5358575e5669564b4d5855796b5c555c584a5c14091708" rel="noreferrer noopener nofollow">[email protected]</a> to s
==============================================================================
Task : Get sources
Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version : 1.0.0
Author : Microsoft
Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Syncing repository: DjangoPortal (Git)
##[command]git version
git version 2.30.0
##[command]git lfs version
git-lfs/2.13.2 (GitHub; linux amd64; go 1.15.5)
##[command]git init "/home/vsts/work/1/s"
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/vsts/work/1/s/.git/
##[command]git remote add origin https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99abfbe0edfceaeaf6ffedeef8ebfcd9fdfcefb7f8e3ecebfcb7faf6f4" rel="noreferrer noopener nofollow">[email protected]</a>/2bytessoftware/BetaPortal/_git/DjangoPortal
##[command]git config gc.auto 0
##[command]git config --get-all http.https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0331617a776670706c657774627166436766752d62797671662d606c6e" rel="noreferrer noopener nofollow">[email protected]</a>/2bytessoftware/BetaPortal/_git/DjangoPortal.extraheader
##[command]git config --get-all http.proxy
##[command]git config http.version HTTP/1.1
##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" fetch --force --tags --prune --progress --no-recurse-submodules origin
remote: Azure Repos
remote:
remote: Found 1656 objects to send. (393 ms)
Receiving objects: 0% (1/1656)

Receiving objects: 100% (1656/1656), 5.48 MiB | 23.08 MiB/s, done.
Resolving deltas: 0% (0/925)

Resolving deltas: 100% (925/925), done.
From https://dev.azure.com/2bytessoftware/BetaPortal/_git/DjangoPortal
* [new branch] Release-0.1 -> origin/Release-0.1
* [new branch] dev -> origin/dev
* [new branch] main -> origin/main
##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" fetch --force --tags --prune --progress --no-recurse-submodules origin +163eb3fa1f8b2c123a2d6de091d8650941e461a9:refs/remotes/origin/163eb3fa1f8b2c123a2d6de091d8650941e461a9
From https://dev.azure.com/2bytessoftware/BetaPortal/_git/DjangoPortal
* [new ref] 163eb3fa1f8b2c123a2d6de091d8650941e461a9 -> origin/163eb3fa1f8b2c123a2d6de091d8650941e461a9
##[command]git checkout --progress --force 163eb3fa1f8b2c123a2d6de091d8650941e461a9
Note: switching to '163eb3fa1f8b2c123a2d6de091d8650941e461a9'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

git switch -c <new-branch-name>

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 163eb3f deploy
##[section]Finishing: Checkout <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c28060d020b033c031e180d002c3e0900090d1f09415c425d" rel="noreferrer noopener nofollow">[email protected]</a> to s
##[section]Starting: Use Python 3.8
==============================================================================
Task : Use Python version
Description : Use the specified version of Python from the tool cache, optionally adding it to the PATH
Version : 0.181.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/tool/use-python-version
==============================================================================
Found tool in cache: Python 3.8.7 x64
Prepending PATH environment variable with directory: /opt/hostedtoolcache/Python/3.8.7/x64
Prepending PATH environment variable with directory: /opt/hostedtoolcache/Python/3.8.7/x64/bin
##[section]Finishing: Use Python 3.8
##[section]Starting: Install requirements
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.182.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
[command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/3bf6fcdc-6048-4645-8fa5-2c12a1e26ff6.sh
Collecting pip
Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
Successfully installed pip-21.0.1
ERROR: Could not find a version that satisfies the requirement setup
ERROR: No matching distribution found for setup
Collecting django-easy-pdf>=0.1.1<0.2.0
Cloning git://github.com/geolffreym/django-easy-pdf.git to /tmp/pip-install-b8ox881f/django-easy-pdf_350c282f211f406dbd269b059bf96f23
Running command git clone -q git://github.com/geolffreym/django-easy-pdf.git /tmp/pip-install-b8ox881f/django-easy-pdf_350c282f211f406dbd269b059bf96f23
WARNING: Requested django-easy-pdf>=0.1.1<0.2.0 from git+git://github.com/geolffreym/django-easy-pdf.git#egg=django-easy-pdf>=0.1.1<0.2.0 (from -r requirements.txt (line 22)), but installing version 0.1.2.dev1
Collecting asgiref
Downloading asgiref-3.3.1-py3-none-any.whl (19 kB)
Collecting autopep8
Downloading autopep8-1.5.5-py2.py3-none-any.whl (44 kB)
Collecting Django
Downloading Django-3.1.7-py3-none-any.whl (7.8 MB)
Collecting pycodestyle
Downloading pycodestyle-2.6.0-py2.py3-none-any.whl (41 kB)
Collecting pytz
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting sqlparse
Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
Collecting Unipath
Downloading Unipath-1.1.tar.gz (30 kB)
Collecting dj-database-url
Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
Collecting python-decouple
Downloading python_decouple-3.4-py3-none-any.whl (9.5 kB)
Collecting gunicorn
Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
Collecting whitenoise
Downloading whitenoise-5.2.0-py2.py3-none-any.whl (19 kB)
Collecting psycopg2-binary
Downloading psycopg2_binary-2.8.6-cp38-cp38-manylinux1_x86_64.whl (3.0 MB)
Collecting django-storages[azure]
Downloading django_storages-1.11.1-py3-none-any.whl (42 kB)
Collecting dj-places
Downloading dj_places-4.0.0-py2.py3-none-any.whl (10 kB)
Collecting django-sendgrid-v5
Downloading django_sendgrid_v5-0.9.1-py2.py3-none-any.whl (8.4 kB)
Collecting Django-Verify-Email
Downloading Django_Verify_Email-0.0.5-py3-none-any.whl (25 kB)
Collecting stripe
Downloading stripe-2.56.0-py2.py3-none-any.whl (204 kB)
Collecting django-phonenumber-field[phonenumberslite]
Downloading django_phonenumber_field-5.0.0-py3-none-any.whl (53 kB)
Collecting babel
Downloading Babel-2.9.0-py2.py3-none-any.whl (8.8 MB)
Collecting django-countries
Downloading django_countries-7.0-py3-none-any.whl (791 kB)
Collecting reportlab
Downloading reportlab-3.5.59-cp38-cp38-manylinux2010_x86_64.whl (2.6 MB)
Collecting xhtml2pdf
Downloading xhtml2pdf-0.2.5.tar.gz (100 kB)
Collecting pillow>=4.0.0
Downloading Pillow-8.1.1-cp38-cp38-manylinux1_x86_64.whl (2.2 MB)
Collecting html5lib>=1.0
Downloading html5lib-1.1-py2.py3-none-any.whl (112 kB)
Collecting pyPdf2
Downloading PyPDF2-1.26.0.tar.gz (77 kB)
Collecting six
Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting python-bidi>=0.4.2
Downloading python_bidi-0.4.2-py2.py3-none-any.whl (30 kB)
Collecting arabic-reshaper>=2.1.0
Downloading arabic_reshaper-2.1.1.tar.gz (18 kB)
Collecting future
Downloading future-0.18.2.tar.gz (829 kB)
Requirement already satisfied: setuptools in ./antenv/lib/python3.8/site-packages (from arabic-reshaper>=2.1.0->xhtml2pdf->-r requirements.txt (line 23)) (49.2.1)
Collecting webencodings
Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Collecting toml
Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting phonenumberslite>=7.0.2
Downloading phonenumberslite-8.12.19-py2.py3-none-any.whl (450 kB)
Collecting sendgrid>=5.0.0
Downloading sendgrid-6.6.0-py3-none-any.whl (74 kB)
Collecting python-http-client>=3.0.0
Downloading python_http_client-3.3.2.tar.gz (7.8 kB)
Collecting starkbank-ecdsa>=1.0.0
Downloading starkbank-ecdsa-1.1.0.tar.gz (12 kB)
Collecting azure-storage-blob<12.0.0,>=1.3.1
Downloading azure_storage_blob-2.1.0-py2.py3-none-any.whl (88 kB)
Collecting azure-storage-common~=2.1
Downloading azure_storage_common-2.1.0-py2.py3-none-any.whl (47 kB)
Collecting azure-common>=1.1.5
Downloading azure_common-1.1.26-py2.py3-none-any.whl (12 kB)
Collecting requests
Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting python-dateutil
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting cryptography
Downloading cryptography-3.4.6-cp36-abi3-manylinux2014_x86_64.whl (3.2 MB)
Collecting certifi>=2017.4.17
Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Collecting chardet<5,>=3.0.2
Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting idna<3,>=2.5
Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting urllib3<1.27,>=1.21.1
Downloading urllib3-1.26.3-py2.py3-none-any.whl (137 kB)
Collecting cffi>=1.12
Downloading cffi-1.14.5-cp38-cp38-manylinux1_x86_64.whl (411 kB)
Collecting pycparser
Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
Using legacy 'setup.py install' for django-easy-pdf, since package 'wheel' is not installed.
Using legacy 'setup.py install' for xhtml2pdf, since package 'wheel' is not installed.
Using legacy 'setup.py install' for arabic-reshaper, since package 'wheel' is not installed.
Using legacy 'setup.py install' for python-http-client, since package 'wheel' is not installed.
Using legacy 'setup.py install' for starkbank-ecdsa, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Unipath, since package 'wheel' is not installed.
Using legacy 'setup.py install' for future, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pyPdf2, since package 'wheel' is not installed.
Installing collected packages: pycparser, urllib3, six, idna, chardet, cffi, certifi, webencodings, sqlparse, requests, pytz, python-dateutil, pillow, future, cryptography, azure-common, asgiref, starkbank-ecdsa, reportlab, python-http-client, python-bidi, pyPdf2, html5lib, Django, azure-storage-common, arabic-reshaper, xhtml2pdf, toml, sendgrid, pycodestyle, phonenumberslite, django-storages, django-phonenumber-field, azure-storage-blob, whitenoise, Unipath, stripe, python-decouple, psycopg2-binary, gunicorn, Django-Verify-Email, django-sendgrid-v5, django-easy-pdf, django-countries, dj-places, dj-database-url, babel, autopep8
Running setup.py install for future: started
Running setup.py install for future: finished with status 'done'
Running setup.py install for starkbank-ecdsa: started
Running setup.py install for starkbank-ecdsa: finished with status 'done'
Running setup.py install for python-http-client: started
Running setup.py install for python-http-client: finished with status 'done'
Running setup.py install for pyPdf2: started
Running setup.py install for pyPdf2: finished with status 'done'
Running setup.py install for arabic-reshaper: started
Running setup.py install for arabic-reshaper: finished with status 'done'
Running setup.py install for xhtml2pdf: started
Running setup.py install for xhtml2pdf: finished with status 'done'
Running setup.py install for Unipath: started
Running setup.py install for Unipath: finished with status 'done'
Running setup.py install for django-easy-pdf: started
Running setup.py install for django-easy-pdf: finished with status 'done'
Successfully installed Django-3.1.7 Django-Verify-Email-0.0.5 Unipath-1.1 arabic-reshaper-2.1.1 asgiref-3.3.1 autopep8-1.5.5 azure-common-1.1.26 azure-storage-blob-2.1.0 azure-storage-common-2.1.0 babel-2.9.0 certifi-2020.12.5 cffi-1.14.5 chardet-4.0.0 cryptography-3.4.6 dj-database-url-0.5.0 dj-places-4.0.0 django-countries-7.0 django-easy-pdf-0.1.2.dev1 django-phonenumber-field-5.0.0 django-sendgrid-v5-0.9.1 django-storages-1.11.1 future-0.18.2 gunicorn-20.0.4 html5lib-1.1 idna-2.10 phonenumberslite-8.12.19 pillow-8.1.1 psycopg2-binary-2.8.6 pyPdf2-1.26.0 pycodestyle-2.6.0 pycparser-2.20 python-bidi-0.4.2 python-dateutil-2.8.1 python-decouple-3.4 python-http-client-3.3.2 pytz-2021.1 reportlab-3.5.59 requests-2.25.1 sendgrid-6.6.0 six-1.15.0 sqlparse-0.4.1 starkbank-ecdsa-1.1.0 stripe-2.56.0 toml-0.10.2 urllib3-1.26.3 webencodings-0.5.1 whitenoise-5.2.0 xhtml2pdf-0.2.5
##[section]Finishing: Install requirements
##[section]Starting: Archive files
==============================================================================
Task : Archive files
Description : Compress files into .7z, .tar.gz, or .zip
Version : 2.179.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/archive-files
==============================================================================
Found 27 files
Archiving file: .env
Archiving file: .git
Archiving file: .gitignore
Archiving file: .vscode
Archiving file: Dockerfile
Archiving file: LICENSE.md
Archiving file: Procfile
Archiving file: README.md
Archiving file: antenv
Archiving file: app
... 17 more ...
files=.env
files=.git
files=.gitignore
files=.vscode
files=Dockerfile
files=LICENSE.md
files=Procfile
files=README.md
files=antenv
files=app
files=authentication
files=azure-pipelines-1.yml
files=azure-pipelines-old.yml
files=azure-pipelines-release-0.1.yml
files=core
files=docker-compose.yml
files=gunicorn-cfg.py
files=manage.py
files=modelerapp
files=nginx
files=package.json
files=qaapp
files=reports
files=requirements.txt
files=runtime.txt
files=staticfiles
files=templates
[command]/usr/bin/zip -r /home/vsts/work/1/a/375.zip .env .git .gitignore .vscode Dockerfile LICENSE.md Procfile README.md antenv app authentication azure-pipelines-1.yml azure-pipelines-old.yml azure-pipelines-release-0.1.yml core docker-compose.yml gunicorn-cfg.py manage.py modelerapp nginx package.json qaapp reports requirements.txt runtime.txt staticfiles templates
adding: .env (deflated 7%)
...
adding: templates/admin/base_site.html (deflated 40%)
##[section]Finishing: Archive files
##[section]Starting: Upload package
==============================================================================
Task : Publish pipeline artifact
Description : Publish a local directory or file as a named artifact for the current pipeline
Version : 0.140.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/publish-pipeline-artifact
==============================================================================
Uploading pipeline artifact from /home/vsts/work/1/a/375.zip for build #375
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session e9c26282-ca5c-469a-9647-6e557ee1bf9b
DedupManifestArtifactClient will correlate http requests with X-TFS-Session e9c26282-ca5c-469a-9647-6e557ee1bf9b
1 files processed.
Processed 1 files from /home/vsts/work/1/a successfully.
Uploading 1 files from directory /home/vsts/work/1/a.
Uploaded 0 out of 103,801,267 bytes.
Uploading 1 files from directory /home/vsts/work/1/a.
Uploaded 52,660,878 out of 103,801,267 bytes.
Uploaded 82,356,390 out of 103,801,447 bytes
Content upload is done!

Content upload statistics:
Total Content: 207.4 MB
Physical Content Uploaded: 78.0 MB
Logical Content Uploaded: 82.4 MB
Compression Saved: 4.3 MB
Deduplication Saved: 125.1 MB
Number of Chunks Uploaded: 1,047
Total Number of Chunks: 5,036

Associated artifact 126 with build 375
ApplicationInsightsTelemetrySender correlated 2 events with X-TFS-Session e9c26282-ca5c-469a-9647-6e557ee1bf9b
Uploading pipeline artifact finished.
##[section]Finishing: Upload package
##[section]Starting: Checkout <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a2e000b040d053a05181e0b062a380f060f0b190f475a445b" rel="noreferrer noopener nofollow">[email protected]</a> to s
==============================================================================
Task : Get sources
Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version : 1.0.0
Author : Microsoft
Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: DjangoPortal (Git)
##[section]Finishing: Checkout <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d692bcb7b8b1b986b9a4a2b7ba9684b3bab3b7a5b3fbe6f8e7" rel="noreferrer noopener nofollow">[email protected]</a> to s
##[section]Starting: Finalize Job
Cleaning up task key
Start cleaning up orphan processes.
##[section]Finishing: Finalize Job
##[section]Finishing: BuildJob

这是部署日志

 ##[section]Starting: DeploymentJob
##[section]Starting: Initialize job
Agent name: 'Hosted Agent'
Agent machine name: 'fv-az192-236'
Current agent version: '2.182.1'
##[group]Operating System
Ubuntu
20.04.2
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-20.04
Version: 20210219.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20210219.1/images/linux/Ubuntu2004-README.md
##[endgroup]
Current image version: '20210219.1'
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Downloading task: DownloadPipelineArtifact (1.2.5)
Downloading task: UsePythonVersion (0.181.0)
Downloading task: AzureWebApp (1.182.0)
Checking job knob settings.
Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY}
Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG}
Finished checking job knob settings.
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Download Artifact
==============================================================================
Task : Download pipeline artifact
Description : Download a named artifact from a pipeline to a local path
Version : 1.2.5
Author : Microsoft Corporation
Help : Download a named artifact from a pipeline to a local path
==============================================================================
Download from the specified build: #375
Download artifact to: /home/vsts/work/1/
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 13ea3dca-de9a-4a81-b2b7-013f9bc2809a
Downloading 1 pipeline artifacts...
DedupManifestArtifactClient will correlate http requests with X-TFS-Session 13ea3dca-de9a-4a81-b2b7-013f9bc2809a
Start downloading artifact - drop
Minimatch patterns: [**]
Filtered 1 files from the Minimatch filters supplied.
Downloaded 0.0 MB out of 103.8 MB (0%).
Downloaded 103.8 MB out of 103.8 MB (100%).

Download statistics:
Total Content: 103.8 MB
Physical Content Downloaded: 99.5 MB
Compression Saved: 4.3 MB
Local Caching Saved: 0.0 MB
Chunks Downloaded: 1,337
Nodes Downloaded: 4

Download completed.
ApplicationInsightsTelemetrySender correlated 2 events with X-TFS-Session 13ea3dca-de9a-4a81-b2b7-013f9bc2809a
Downloading artifact finished.
##[section]Finishing: Download Artifact
##[section]Starting: Use Python version
==============================================================================
Task : Use Python version
Description : Use the specified version of Python from the tool cache, optionally adding it to the PATH
Version : 0.181.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/tool/use-python-version
==============================================================================
Found tool in cache: Python 3.8.7 x64
Prepending PATH environment variable with directory: /opt/hostedtoolcache/Python/3.8.7/x64
Prepending PATH environment variable with directory: /opt/hostedtoolcache/Python/3.8.7/x64/bin
##[section]Finishing: Use Python version
##[section]Starting: Deploy Azure Web App : staging
==============================================================================
Task : Azure Web App
Description : Deploy an Azure Web App for Linux or Windows
Version : 1.182.0
Author : Microsoft Corporation
Help : https://aka.ms/azurewebapptroubleshooting
==============================================================================
Got service connection details for Azure App Service:''
Package deployment using ZIP Deploy initiated.
Deploy logs can be viewed at https://-staging.scm.azurewebsites.net/api/deployments/37a1ee6e-7258-4e82-b769-2ab660a88de9/log
Successfully deployed web package to App Service.
Successfully updated deployment History at https://-staging.scm.azurewebsites.net/api/deployments/3751614723426245
App Service Application URL: http://-staging.azurewebsites.net
##[section]Finishing: Deploy Azure Web App : staging
##[section]Starting: Finalize Job
Cleaning up task key
Start cleaning up orphan processes.
##[section]Finishing: Finalize Job
##[section]Finishing: DeploymentJob

然后当应用程序运行时就会发生这种情况

   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/site/wwwroot/core/wsgi.py", line 9, in <module>
from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
[2021-03-02 04:42:36 +0000] [38] [INFO] Worker exiting (pid: 38)
[2021-03-02 04:42:36 +0000] [36] [INFO] Shutting down: Master
[2021-03-02 04:42:36 +0000] [36] [INFO] Reason: Worker failed to boot.

我进入 SCM bash 控制台并检查了 (antenv) root@39e2ab319aff:/home/site/wwwroot# ls ./antenv/lib/python3.8/site-packages 以及所有文件在那里,但是执行 pip freeze 显示没有安装任何依赖项,并且当我尝试 python manage.py 时,它也没有安装依赖项

我不知道它可能是什么,我确信这可能是我遗漏的一些简单的东西,我将日志与正在运行的测试实例的日志进行了比较,并且日志基本上是相同的

最佳答案

我用一个简单的 Django 应用程序测试了这个工作流程,没有任何问题。

与你不同的两件事是:

  1. 我使用版本 python 3.7 但你使用 python 3.8

  2. 我使用 pip 命令,但你使用 pip3:

     - script: |
    python -m venv antenv
    source antenv/bin/activate
    python -m pip install --upgrade pip
    pip install setup
    pip install -r requirements.txt
    workingDirectory: $(projectRoot)
    displayName: "Install requirements"

document 可以看出,它也使用 pip 而不是 pip3。

如果没有帮助,就像我的评论一样,可能您的重要文件不存在于根路径中,请检查此工作流程是否适合您:

# Python Django
# Test a Django project on multiple versions of Python.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/python
pool:
vmImage: 'Ubuntu 16.04'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: 3.5
architecture: 'x64'

- task: PythonScript@0
displayName: 'Export project path'
inputs:
scriptSource: 'inline'
script: |
"""Search all subdirectories for `manage.py`."""
from glob import iglob
from os import path
# Python >= 3.5
manage_py = next(iglob(path.join('**', 'manage.py'), recursive=True), None)
if not manage_py:
raise SystemExit('Could not find a Django project')
project_location = path.dirname(path.abspath(manage_py))
print('Found Django project in', project_location)
print('##vso[task.setvariable variable=projectRoot]{}'.format(project_location))
- script: |
python -m pip install --upgrade pip setuptools wheel django
pip install -r requirements.txt
pip install unittest-xml-reporting
displayName: 'Install prerequisites'

- script: |
pushd '$(projectRoot)'
python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
condition: succeededOrFailed()
displayName: 'Run tests'

- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: "**/TEST-*.xml"
testRunTitle: 'Python $(PYTHON_VERSION)'

关于python - requirements.txt 依赖项未与 Azure Web 应用程序上的代码一起部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66448552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com