Python pip install requests[security] vs pip install requests:区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31811949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip install requests[security] vs pip install requests: Difference
提问by Ymartin
I am using Ubuntu 14.04 (Trusty Tahr) with Python version 2.7.6. Today, when I created a new virtualenv
and tried doing pip install requests
, I got the error InsecurePlatformWarning
.
我正在使用 Ubuntu 14.04 (Trusty Tahr) 和 Python 2.7.6 版。今天,当我创建一个新的virtualenv
并尝试做时pip install requests
,我得到了错误InsecurePlatformWarning
。
I resolved this issue by following the instructions in SSL InsecurePlatform error when using Requests package.
我按照SSL InsecurePlatform error when using Requests package 中的说明解决了这个问题。
But I want to understand what is the actual difference between these two commands:
pip install requests[security]
and pip install requests
.
但我想了解这两个命令之间的实际区别是什么:
pip install requests[security]
和pip install requests
.
Why does the former install three additional packages?
Are there any things that I need to take care about when I push the code to production?
Do they both behave the same generally?
为什么前者要安装三个额外的包?
当我将代码推送到生产环境时,有什么需要注意的地方吗?
他们都表现得一般吗?
采纳答案by citruspi
Why does the former install 3 additional packages?
为什么前者要安装 3 个额外的包?
Using requests[security]
instead of requests
will install three additional packages:
使用requests[security]
而不是requests
安装三个额外的包:
- pyOpenSSL
- cryptography
- idna
- 开放式SSL
- 密码学
- 伊德娜
These are defined in extras_requires
, as optional features with additional dependencies.
这些在 中定义extras_requires
为具有附加依赖项的可选功能。
Are there any things that I need to take care about when I push the code to production?
当我将代码推送到生产环境时,有什么需要注意的地方吗?
You'd want to make sure that you are able to install those additional packages without any issues and that any changes to the way SSL connections work don't affect your usage.
您希望确保您能够安装这些附加软件包而不会出现任何问题,并且 SSL 连接工作方式的任何更改都不会影响您的使用。
Do they both behave the same generally?
他们都表现得一般吗?
Using these packages as opposed to the default standard library options will allow for more secure SSL connections.
使用这些包而不是默认的标准库选项将允许更安全的 SSL 连接。
For more information, here's the pull request where it was merged inand here is the issue where it was discussed.
欲了解更多信息,这里的拉请求,其中它在合并和这里是它讨论了这个问题。
(From the comments, for when GitHub goes away):
(来自评论,当 GitHub 消失时):
So right now the SSL connections when you use pyOpenSSL, ndg-httspclient, and pyasn1 are more secure than if you just use the stdlib options. However it's hard to actually remember those three things. It would be cool if requests would add an extra to it's setup.py so that people can install requests with betterssl (Donald Stufft)
因此,现在使用 pyOpenSSL、ndg-httspclient 和 pyasn1 时的 SSL 连接比仅使用 stdlib 选项更安全。然而,很难真正记住这三件事。如果请求会在 setup.py 中添加额外内容,以便人们可以使用 Betterssl(Donald Stufft)安装请求,那将会很酷
Also by default requests can't connect to some sites on OS X because of ancient OpenSSL. Using the above 3 packages makes it possible. (Donald Stufft)
此外,由于古老的 OpenSSL,默认情况下请求无法连接到 OS X 上的某些站点。使用上面的3个包就可以了。(唐纳德·斯塔夫特)