首页 > 解决方案 > pip 安装时出现 Azure DevOps python 提要错误

问题描述

建立了我的 Azure DevOps python feed 并发布了一个 python 包,但无法将它安装在我的管道中。

天蓝色管道.yml:

- task: PipAuthenticate@1
  displayName: 'Pip Authenticate'
  inputs:
    artifactFeeds: my_feed
    onlyAddExtraIndex: true
- script: pip install my-package==0.0.1234

输出:

##[section]Starting: Pip Authenticate
==============================================================================
Task         : Python pip authenticate
Description  : Authentication task for the pip client used for installing Python distributions
Version      : 1.156.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/pip-authenticate
==============================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
Successfully added auth for 1 internal feeds and 0 external endpoint.
##[section]Finishing: Pip Authenticate

##[section]Starting: CmdLine
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.151.2
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
pip install my-package==0.0.1234
========================== Starting Command Output ===========================
[command]/usr/bin/bash --noprofile --norc /home/user/.../_work/_temp/029c4dab-3726-41d8-896a-ed539e6bc712.sh
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: https://pypi.org/simple, https://build:****@pkgs.dev.azure.com/.../_packaging/.../pypi/simple
Collecting my-package==0.0.1234
  ERROR: Could not find a version that satisfies the requirement my-package==0.0.1234 (from versions: none)
ERROR: No matching distribution found for my-package==0.0.1234
##[error]Bash exited with code '1'.
##[section]Finishing: CmdLine

我怎样才能解决这个问题?提前致谢!

标签: pythonpipazure-devops

解决方案


pip 安装时出现 Azure DevOps python 提要错误

首先,您需要仔细检查0.0.1234提要中该软件包的版本。

其次,根据报错信息,您似乎使用的是Python 2.7.,请尝试将您的 Python 更新为3.6.x.

第三,当您将python更新到3.6.x时,您仍然遇到同样的问题,请尝试使用以下命令将pip升级到最新版本:

py -m pip install --upgrade pip

更新:

感谢 user2809176 分享他的问题的详细解决方案:

包创建过程中使用的 python 版本应该与安装过程中使用的版本相匹配。

例如,如果在 /dist 文件夹中您有 my-package-0.0.1234-py3-none-any.whl,您应该使用 python 版本 3 安装它。否则您将收到此错误消息。

如果您尝试使用 python 3 安装它,我猜 my-package-0.0.1234-py2-none-any.whl 会显示相同的错误。

希望这可以帮助。


推荐阅读