首页 > 解决方案 > 使用 buildspec.yml 在 AWS 上设置 python 环境

问题描述

我有一个本地设备场,它在一些 android 模拟器上通过 Appium 1.6.5 运行 python 2.7.13。我们希望增加曝光率并利用 AWS 设备场。问题是 AWS 只支持 Python 2.7.6 并且他们没有升级计划。

我们至少需要 Python 2.7.9+,因为下面的任何 Python 都不支持带有“请求”包的 SSL。

我们尝试了“request[security] == 2.9.1”,但它在 Wheel 包中引入了 AWS 不支持的依赖项。

在 Windows 和 AWS 上使用 python 2.7.6 时,使用 pip 下载软件包时出现以下错误...

... 收集密码学>=2.2.1(来自 pyOpenSSL>=0.13->requests[security]==2.9.1->-r /tmp/scratchzAHCQI.scratch/test-packagep3mb8i/requirements.txt(第 5 行)) /tmp/scratchzAHCQI.scratch/tmpZjjNAE/local/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl .py : 90:InsecurePlatformWarning:真正的 SSLContext 对象不可用。这会阻止 urllib3 正确配置 SSL,并可能导致某些 SSL 连接失败。有关详细信息,请参阅 https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning。InsecurePlatformWarning 正在下载 https://files.pythonhosted.org/packages/22/21/233e38f74188db94e8451ef6385754a98f3cad9b59bedf3a8e8b14988be4/cryptography-2.3.1.tar.gz (449kB) 命令 python setup.py egg_info 的完整输出:回溯(最近一次调用最后一次):文件“”,第 20 行,文件“/tmp/pip-build-nqoNP_/cryptography/setup.py”,第 28 行,在“密码学需要 setuptools 18.5 或更高版本,请升级到”运行时错误:密码学需要 setuptools 18.5 或更高版本,请升级到更新版本的 setuptools

---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in

/tmp/pip-build-nqoNP_/cryptography /tmp/scratchzAHCQI.scratch/tmpZjjNAE/local/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl .py :90:InsecurePlatformWarning : 真正的 SSLContext 对象不可用。这会阻止 urllib3 正确配置 SSL,并可能导致某些 SSL 连接失败。有关详细信息,请参阅 https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning。InsecurePlatformWarning /tmp/scratchzAHCQI.scratch/tmpZjjNAE/local/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:90:InsecurePlatformWarning:真正的 SSLContext 对象不可用。这会阻止 urllib3 正确配置 SSL,并可能导致某些 SSL 连接失败。有关详细信息,请参阅 https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning。InsecurePlatformWarning 您正在使用 pip 版本 7.1.2,但版本 18.0 可用。您应该考虑通过“pip install --upgrade pip”命令进行升级。

一位 AWS 支持工程师提到我们可以设置自己的环境来支持新版本的 Python。但是,文档非常混乱,因为它没有指定应该调用什么“技术规范”文件(我假设是 buildspec.yml),我应该把它放在哪里,我们是否应该仍然使用轮子还是只使用 pip?

我可以使用 apt 还是应该使用 yum?

我浏览了互联网,但找不到与 python 和 AWS 技术规范相关的任何内容。我要做的就是安装 Python 2.7.9,安装需求并触发测试,并能够发布到 https REST 服务。

以前有没有人必须解决这个问题?

标签: python-2.7python-requestsaws-device-farm

解决方案


您可以从默认 2.7.6 与可选 3.4.3 中进行选择。按照这篇文章设置 python 3 环境:https ://forums.aws.amazon.com/message.jspa?messageID=865585#868262


推荐阅读