简体   繁体   English

pip install insecureplatformwarning snimissingwarning ubuntu 14.04 python 2.7.6

[英]pip install insecureplatformwarning snimissingwarning ubuntu 14.04 python 2.7.6

I'm getting insecure platform and sni missing warnings while running pip install. 运行pip安装时,平台不安全,并且sni缺少警告。 I've been trying to follow the instructions suggested in the error messages below without luck: 我一直在尝试按照以下错误消息中的建议进行操作,但运气不佳:

https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2 https://urllib3.readthedocs.io/zh-CN/latest/security.html#insecureplatformwarning https://urllib3.readthedocs.io/zh-CN/latest/security.html#snimissingwarning https://urllib3.readthedocs.io/zh-CN Latest / user-guide.html#ssl-py2

I wrote up a small Vagrant file & Chef cookbook to demonstrate the issue and maybe get some help. 我写了一个小的Vagrant文​​件和Chef食谱来演示该问题,并可能会得到一些帮助。 The warnings show up before every install of a pip package. 警告会在每次安装pip软件包之前显示。 I've also tried various combos of pip install options and varying the version pip (8.1.2 vs 9.0.1). 我还尝试了各种pip安装选项组合,并更改了pip版本(8.1.2与9.0.1)。 Any help appreciated. 任何帮助表示赞赏。

Public GitHub Repo containing the code below: https://github.com/marc-swingler/urllib_issue 包含以下代码的公共GitHub存储库: https : //github.com/marc-swingler/urllib_issue

Requirements: Vagrant and VirtualBox 要求:无业游民和VirtualBox

To Run: vagrant up 运行:无所事事

UPDATE:: Found this thread https://github.com/pypa/pip/issues/4098 更新::找到了这个线程https://github.com/pypa/pip/issues/4098

Turns out pip 9.0.1 doesn't play nice due to libs that come bundled with it. 事实证明,由于捆绑了libs,pip 9.0.1不能很好地播放。 Also, install ndg-httpsclient rather than urllib3 and/or requests. 另外,请安装ndg-httpsclient而不是urllib3和/或请求。 The apt packages mentioned in the user-guide are not required, and no need to build from scratch, you can use wheels. 不需要用户指南中提到的apt软件包,也不需要从头开始构建,可以使用轮子。 Once ndg-httpsclient is installed the warnings go away and additional pip installs go smoothly. 安装ndg-httpsclient后,警告将消失,其他pip安装也将顺利进行。 I also have a version of this where I bootstrap pip with the apt python-pip package that works. 我也有一个这样的版本,可以使用apt python-pip软件包引导pip。 (I'll post it if anyone is interested.) Apt installs pip v1.5.4 initially. (如果有人感兴趣,我会发布。)Apt最初会安装pip v1.5.4。 The script then updates to pip 8.1.2 and proceeds similarly to the code below. 然后,脚本更新为pip 8.1.2,并与以下代码类似地进行。 Just requires removing the "--disable-pip-version-check" option when upgrading pip. 只需在升级pip时删除“ --disable-pip-version-check”选项即可。

Vagrantfile: Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "ubuntu/trusty64"
    config.vm.network "private_network", type: "dhcp"
    config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
    config.vm.provision "chef_solo" do |chef|
            chef.add_recipe("foo")
    end
    config.vm.provider "virtualbox" do |v|
            v.memory = 4096
    end
end

cookbooks/foo/recipes/default.rb: 食谱/ foo /食谱/default.rb:

pip_installer_path = '/tmp/get-pip.py'
remote_file "download_pip_installer" do
    path pip_installer_path
    source 'https://bootstrap.pypa.io/get-pip.py'
    owner 'root'
    group 'root'
    mode '0500'
    not_if 'which pip'
end
execute 'bootstrap_pip' do
    command "python #{pip_installer_path}"
    not_if "which pip"
end
cookbook_file 'delete_pip_installer' do
    path pip_installer_path
    action :delete
end

pip_packages = {
    'pip' => { 'version' => '8.1.2', 'extras' => nil },
    'ndg-httpsclient' => { 'version' => '0.4.3', 'extras' => nil },
    'botocore' => { 'version' => '1.7.18', 'extras' => nil },
    'pystache' => { 'version' => '0.5.4', 'extras' => nil }
}
pip_packages.each do |package_name, package_info|
    package_version = package_info['version']
    package_extras = package_info['extras']
    package_spec = package_name
    unless package_extras.nil? or package_extras.length < 1
        package_spec = package_spec + '['
        package_extras.each do |package_extra|
            package_spec = package_spec + package_extra + ','
        end
        package_spec[-1] = ']'
    end
    package_spec = package_spec + '==' + package_version
    execute package_spec do
        command "pip --disable-pip-version-check install -U #{package_spec}"
        not_if "test #{package_version} = `pip --disable-pip-version-check list 2>/dev/null | sed -rn 's/^#{package_name} \\(([0-9.]+)\\)/\\1/p'`"
    end
end

cookbooks/metadata.rb 食谱/metadata.rb

name             'foo'
maintainer       'foo'
maintainer_email 'foo@foo.com'
license          'foo'
description      'foo'
long_description 'foo'
version          '0.0.0'

As mentioned above I found a solution. 如上所述,我找到了解决方案。 https://github.com/marc-swingler/urllib_issue https://github.com/marc-swingler/urllib_issue

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

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