[英]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:
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.