简体   繁体   English

virtualenv 中的间歇性 pip 安装错误?

[英]Intermittent pip install error in virtualenv?

For the commands below:对于以下命令:

virtualenv --system-site-packages `pwd`/.test

# load virtual environment
source `pwd`/.test/bin/activate

# install required python modules
# for some reason argparse is not included with credstash install but required at runtime :(
#PYPI_REPO=http://${PYPI_DNS}/aes/release/+simple/
#PYPI_DNS is internal company DNS 
pip install pip --upgrade -i ${PYPI_REPO} --quiet
pip install argparse==1.4.0 -i ${PYPI_REPO} --trusted-host ${PYPI_DNS} --quiet
pip install credstash==1.14.0 -i ${PYPI_REPO} --trusted-host ${PYPI_DNS} --quiet

This is sometimes work successfully.这有时是成功的。

  1. However sometimes it will fail at the installation of argparse:但是有时它会在安装 argparse 时失败:

    Could not find a version that satisfies the requirement argparse==1.4.0 (from versions: ) No matching distribution found for argparse==1.4.0找不到满足 argparse==1.4.0 要求的版本(来自版本:)找不到与 argparse==1.4.0 匹配的发行版

  2. Then at other times, it will fail installing credstash:然后在其他时候,它会安装 credstash 失败:

    Could not find a version that satisfies the requirement boto3>=1.1.1 (from credstash==1.14.0) (from versions: ) No matching distribution found for boto3>=1.1.1 (from credstash==1.14.0)找不到满足要求的版本 boto3>=1.1.1(来自 credstash==1.14.0)(来自版本:)没有找到与 boto3>=1.1.1 匹配的发行版(来自 credstash==1.14.0)

I cannot find the reason when it fails and when it succeeds.我找不到它失败时和成功时的原因。

Note that the commands above are from a xxx.sh file which is run as part of the EC2 UserData script - it works almost 90% during EC2 startup.请注意,上面的命令来自 xxx.sh 文件,该文件作为 EC2 UserData 脚本的一部分运行 - 它在 EC2 启动期间几乎可以正常工作 90%。

However, it works 10% of the time when I run the xxx.sh manually (the sh runs an ansible playbook after the credstash is installed - hence running manually is quicker way to test the playbook) while SSHing on the EC2 instance - the error switches between the 2 error messages I stated above.但是,当我手动运行 xxx.sh(安装 credstash 后 sh 运行 ansible playbook - 因此手动运行是测试 playbook 的更快方法)时,它在 10% 的时间内工作,而在 EC2 实例上运行SSH - 错误在我上面提到的 2 条错误消息之间切换。 I am not python developer so it might be something I missing, please if you can point me to the right direction?我不是 python 开发人员,所以它可能是我遗漏的东西,如果你能指出我正确的方向吗?

Most likely this intermittent failure can be due to slow response from your internal PYPI_REPO.这种间歇性故障很可能是由于您的内部 PYPI_REPO 响应缓慢。 To confirm it you can use -v option in your pip install command, to increase the verbosity of pip output.要确认它,您可以在 pip install 命令中使用-v选项,以增加 pip 输出的详细程度。 You can then analyze the pip output to check where the failure occurs.然后,您可以分析 pip 输出以检查故障发生的位置。

You can also set a larger timeout value using --timeout 60 option in your pip command.您还可以在 pip 命令中使用--timeout 60选项设置更大的超时值。 The default timeout value is 15 seconds.默认超时值为 15 秒。 This timeout value can also be set via pip configuration file (%VIRTUAL_ENV%\\pip.ini).此超时值也可以通过 pip 配置文件 (%VIRTUAL_ENV%\\pip.ini) 设置。

[global]
timeout = 60

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM