卸载Azure功能中的软件包

发布于 2025-01-31 05:31:19 字数 168 浏览 2 评论 0原文

我的Azure函数应用程序(Python)正在抛出一个例外:模块键入没有属性“ _classvar”。解决此问题的方法是卸载Dataclasses软件包。如何使用PIP卸载此软件包在Python Azure函数上?

如果我运行PIP卸载Dataclasses,这会反映出部署吗?

My azure function app(python) is throwing an exception: module typing has no attribute '_classVar'. A fix for this would be to uninstall the dataclasses package. How do I uninstall this package on a python azure function using pip?

If I run pip uninstall dataclasses, will this reflect on deployment?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倦话 2025-02-07 05:31:19

如果您使用的是Python版本3.7或更高版本,则需要使用相同的pip卸载DataClasses来卸载dataclass库。

因为数据级包是python 3.7 dataclass功能的备份。

或者, 如果您仍然想存在dataclasses您可以将Python版本降级到3.6。

有关更多信息,请参阅以下链接:

If you are using python version 3.7 or greater you need to uninstall the dataclass library using the same pip uninstall dataclasses.

As The dataclasses package is a backport of the Python 3.7 dataclass functionality.

Or, if still you want to exist dataclasses you can downgrade your python version to 3.6.

For more information please refer the below links:

空心空情空意 2025-02-07 05:31:19

我也遇到了很多麻烦,试图从具有Python 3.7环境的Azure DevOps管道部署Azure功能,因此我决定将其放置在此处,因为它可能会帮助其他人遇到相同问题。

您需要使用各自的变量来准备以下YAML文件。

    trigger:
    - {{ branch }}
    
    variables:
      # Azure Resource Manager connection created during pipeline creation
      azureSubscription: '{{ azureRmConnection.Id }}'
    
      # Function app name
      functionAppName: '{{ functionAppName }}'
    
      # Agent VM image name
      vmImageName: 'ubuntu-latest'
    
      # Working Directory
      workingDirectory: '{{ workingDirectory }}'
    
    stages:
    - stage: Build
      displayName: Build stage
    
      jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: $(vmImageName)
    
        steps:
        - bash: |
            if [ -f extensions.csproj ]
            then
                dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
            fi
          workingDirectory: $(workingDirectory)
          displayName: 'Build extensions'
        - task: UsePythonVersion@0
          displayName: 'Use Python 3.6'
          inputs:
            versionSpec: 3.6 # Functions V2 supports Python 3.6 as of today
    
        - bash: |
            pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
            rm -rf ./.python_packages/lib/site-packages/dataclasses-0.6*
            rm ./.python_packages/lib/site-packages/dataclasses.py
          workingDirectory: $(workingDirectory)
          displayName: 'Install application dependencies'
        - task: ArchiveFiles@2
          displayName: 'Archive files'
          inputs:
            rootFolderOrFile: '$(workingDirectory)'
            includeRootFolder: false
            archiveType: zip
            archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
            replaceExistingArchive: true
    
        - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
          artifact: drop
    
    - stage: Deploy
      displayName: Deploy stage
      dependsOn: Build
      condition: succeeded()
    
      jobs:
      - deployment: Deploy
        displayName: Deploy
        environment: 'development'
        pool:
          vmImage: $(vmImageName)
    
        strategy:
          runOnce:
            deploy:
    
              steps:
              - task: AzureFunctionApp@1
                displayName: 'Azure functions app deploy'
                inputs:
                  azureSubscription: '$(azureSubscription)'
                  appType: functionAppLinux
                  appName: $(functionAppName)
                  package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

这些是安装需求之后的关键线。txt。这些将从网站包装文件夹中删除包装。

rm -rf ./.python_packages/lib/site-packages/dataclasses-0.6*
rm ./.python_packages/lib/site-packages/dataclasses.py

PIP卸载Dataclasses由于您不在正确的文件夹中而行不通。

希望这有帮助!

I was also having a lot of trouble trying to deploy azure functions from an Azure Devops pipeline with a Python 3.7 environment, so I decided to place this here as it might help someone else with the same problem.

You need to prepare the following yaml file with your respective variables.

    trigger:
    - {{ branch }}
    
    variables:
      # Azure Resource Manager connection created during pipeline creation
      azureSubscription: '{{ azureRmConnection.Id }}'
    
      # Function app name
      functionAppName: '{{ functionAppName }}'
    
      # Agent VM image name
      vmImageName: 'ubuntu-latest'
    
      # Working Directory
      workingDirectory: '{{ workingDirectory }}'
    
    stages:
    - stage: Build
      displayName: Build stage
    
      jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: $(vmImageName)
    
        steps:
        - bash: |
            if [ -f extensions.csproj ]
            then
                dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
            fi
          workingDirectory: $(workingDirectory)
          displayName: 'Build extensions'
        - task: UsePythonVersion@0
          displayName: 'Use Python 3.6'
          inputs:
            versionSpec: 3.6 # Functions V2 supports Python 3.6 as of today
    
        - bash: |
            pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
            rm -rf ./.python_packages/lib/site-packages/dataclasses-0.6*
            rm ./.python_packages/lib/site-packages/dataclasses.py
          workingDirectory: $(workingDirectory)
          displayName: 'Install application dependencies'
        - task: ArchiveFiles@2
          displayName: 'Archive files'
          inputs:
            rootFolderOrFile: '$(workingDirectory)'
            includeRootFolder: false
            archiveType: zip
            archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
            replaceExistingArchive: true
    
        - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
          artifact: drop
    
    - stage: Deploy
      displayName: Deploy stage
      dependsOn: Build
      condition: succeeded()
    
      jobs:
      - deployment: Deploy
        displayName: Deploy
        environment: 'development'
        pool:
          vmImage: $(vmImageName)
    
        strategy:
          runOnce:
            deploy:
    
              steps:
              - task: AzureFunctionApp@1
                displayName: 'Azure functions app deploy'
                inputs:
                  azureSubscription: '$(azureSubscription)'
                  appType: functionAppLinux
                  appName: $(functionAppName)
                  package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

These are the key lines after installing the requirements.txt. These will remove the package from the site-packages folder.

rm -rf ./.python_packages/lib/site-packages/dataclasses-0.6*
rm ./.python_packages/lib/site-packages/dataclasses.py

pip uninstall dataclasses will not work because you are not in the right folder.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文