pip install 不断询问用户和密码

pip install keep asking user and password

我是私人 PyPI 托管的新手,所以我使用 python 2.7 在 Nexus3 上托管私人 PyPI 存储库,我将以下内容放入 pip.conf:

[global]
extra-index-url = https://username:password@example.com/repository/package/simple

但是,它一直弹出来询问用户和密码。因为我已经在 URL 中传递了用户名和密码,所以它应该直接传递而不用询问吗?谁有同样的情况,你是如何解决的?

根据这个问题线程中的评论,似乎 pip 可能无法处理密码中的特殊字符:

https://github.com/pypa/pip/issues/51

这条评论似乎特别证实了这个问题:

vladignatyev I just ran into the same problem you mentioned, of it asking for user/password interactively. I narrowed down the problem to having a symbol in the password that needs url-encoding. If I don't url-encode the password, the URL can't be parsed. If I do url-encode the password, I think pip isn't url-decoding it before attempting to authenticate.

看来目前唯一的解决方法是使用不带需要 URL 编码字符的密码。

注意:我没有足够的代表发表评论来回复 wholevinski

此错误已在 pull request back in April, it's just not slated to be released until milestone 10.0 中修复,尚未发布

更新: pip 10.0 现已发布。