简体   繁体   English

如何通过 CLI 从 Azure 工件源安装私有 python package

[英]How to install private python package from Azure Artifact feed via CLI

I have setup a pypi feed in Azure Artifacts, but I can't seem to be able to authenticate via CLI to be able to install the python packages locally.我已经在 Azure Artifacts 中设置了一个 pypi 提要,但我似乎无法通过 CLI 进行身份验证才能在本地安装 python 包。 I want to be able to just run pip install and provide the repo url but I can't get pass the login/verification step.我希望能够只运行pip install并提供 repo url 但我无法通过登录/验证步骤。

I have keyring and artifacts-keyring installed just like MS suggests, but whenever I try to pip install I get a prompt for User and Password like below:就像 MS 建议的那样,我安装了密钥环和artifacts-keyring ,但是每当我尝试keyring安装时,我都会收到用户和密码的提示,如下所示:

C:\Users\user-name-here> pip install -r "url-to-feed-here" package-name
User for pkgs.dev.azure.com: <my MS/DevOps username>
Password: <my MS/DevOps password>
WARNING: 401 Error, Credentials not correct for feed-url-here
ERROR: 401 Client Error: Unauthorized for url: feed-url-here

that always fails to authenticate, and on remote servers via ssh it doesn't even indicate credentials were incorrect just that a 401 http message was returned.始终无法通过身份验证,并且通过 ssh 在远程服务器上,它甚至不表明凭据不正确,只是返回了 401 http 消息。

What doesn't make sense to me is that I'm using the exact same user/password combo to sign into DevOps and create the feed, yet I can't use those credentials to pull packages from it?对我来说没有意义的是,我使用完全相同的用户/密码组合登录 DevOps 并创建提要,但我不能使用这些凭据从中提取包? Does that mean MS has a different set of credentials one must setup to use this?这是否意味着 MS 必须设置一组不同的凭据才能使用它?

All the other questions I've seen have either been about using Pipelines, NuGet, or some other means than straight cli commands which doesn't help, because I want to be using the CLI and possibly scripting this out in something simple later on.我见过的所有其他问题要么是关于使用管道、NuGet,要么是其他一些没有帮助的直接 cli 命令,因为我想使用 CLI 并可能稍后用一些简单的脚本编写出来。

How to install private python package from Azure Artifact feed via CLI如何通过 CLI 从 Azure 工件源安装私有 python package

According to the document Get started with Python packages in Azure Artifacts , it provide two primary ways to connect to a feed to push or pull Python packages:根据文档Get started with Python packages in Azure Artifacts ,它提供了两种主要的方式来连接到 feed 以推送或拉取 ZA7F5F35426B927411FC9231B56382173:

  • Install and use the Python Credential Provider (artifacts-keyring) (preview), which sets up authentication for you.安装并使用 Python Credential Provider (artifacts-keyring)(预览版),它会为您设置身份验证。
  • Manually set up credentials for pip.ini/pip.conf for pushes, or.pypirc for pulls, through a personal access token (PAT).通过个人访问令牌 (PAT) 手动设置用于推送的 pip.ini/pip.conf 或用于拉取的 .pypirc 的凭据。

Looks like you're using option1 from the document to do the install.看起来您正在使用文档中的 option1 进行安装。 I happen to get the same error as you if I use your install command line pip install -r "url-to-feed-here" package-name .如果我使用您的安装命令行pip install -r "url-to-feed-here" package-name我碰巧遇到与您相同的错误。

But, if I use the command line from the document, it works fine:但是,如果我使用文档中的命令行,它可以正常工作:

pip install <package-name> --index-url https://pkgs.dev.azure.com/<your-organization-name>/_packaging/<your-feed-name>/pypi/simple

Note:笔记:

The Python Credential Provider lets the pip and twine commands authenticate by sending you through an authentication flow in your web browser. Python 凭据提供程序允许 pip 和 twine 命令通过在您的 web 浏览器中向您发送身份验证流程来进行身份验证。

My test result:我的测试结果:

在此处输入图像描述

So, please try to use this command line to install private python package from Azure Artifact feed via CLI.因此,请尝试使用此命令行通过 CLI 从 Azure Artifact feed 安装私有 python package。

Besides, you could also try to install the private python package by the second option.此外,您还可以尝试通过第二个选项安装私有 python package。

This worked for me, Hope it will help someone.这对我有用,希望它会帮助别人。

1: create a personal access token (PAT) from settings. 1:从设置中创建个人访问令牌 (PAT)

2: you have to include username and generated token inside the virtual environment by creating a file named pip.conf , which contains the below code 2:您必须在虚拟环境中包含用户名生成的令牌,方法是创建一个名为pip.conf的文件,其中包含以下代码

[global]
index-url=https://username:your_generated_token@pkgs.dev.azure.com/<your-organization-name>/_packaging/<your-feed-name>/pypi/simple

Now try pip install package_name现在尝试pip install package_name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从私人pypiserver安装python包 - Install python package from private pypiserver 如何在构建过程中安装私有 Python 包 - How to Install Private Python Package as Part of Build 从 Azure 源中的 python package 消费 python ZEFE90A8E604A67F6B7D8Z 在本地(非 Azure)Z05B6053C41A2130AFD6B4B 实例 - Consume python package from Azure feed in a local (not Azure) docker instance 从 Azure DevOps Python Artifacts 源安装 pip 不起作用 - pip install from Azure DevOps Python Artifacts feed not working 在 Azure 中安装 python package - Install python package in Azure 我如何使用jenkins从私人github存储库安装python软件包? - How do I install python package from private github repo using jenkins? 如何从私有 bitbucket-git 存储库安装 python 包命名空间 - How to install python package namespace from private bitbucket-git repository GCP Apache Airflow - 如何安装 Python ZEFE90A8E604A76C6840E88D0D 从私有存储库中导入 DAGB7? - GCP Apache Airflow - How to install Python package from a private repository and import on DAG? 如何从私有 Pypi 存储库将 python package 安装到 google Colab? - How can I install a python package to google Colab from a private Pypi repository? 如何从私有 github 存储库安装已分发的 Python package (wheel)? - How to install an already distributable Python package (wheel) from a private github repository?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM