How to suppress pip upgrade warning?

2019-02-11 02:19发布

My pip version was off -- every pip command was saying:

You are using pip version 6.0.8, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

And I didn't like the answers given here: How can I get rid of this warning to upgrade from pip? because they all want to get pip out of sync with the RH version.

So I tried a clean system install with this VagrantFile:

Vagrant.configure("2") do |config|

  config.ssh.username   = 'root'
  config.ssh.password   = 'vagrant'
  config.ssh.insert_key = 'true'

  config.vm.box = "bento/centos-7.3"

  config.vm.provider "virtualbox" do |vb|
    vb.cpus   = "4"
    vb.memory = "2048"
  end

  config.vm.synced_folder "..", "/vagrant"

  config.vm.network "public_network", bridge: "eth0", ip: "192.168.1.31"

  config.vm.provision "shell", inline: <<-SHELL
    set -x

    # Install pip
    yum install -y epel-release
    yum install -y python-pip
    pip freeze   # See if pip prints version warning on fresh OS install.

  SHELL

end

But then I got:

==> default: ++ pip freeze
==> default: You are using pip version 8.1.2, however version 9.0.1 is available.
==> default: You should consider upgrading via the 'pip install --upgrade pip' command.

So it seems that I'm using the wrong commands to install pip. What are correct commands to use?

标签: python pip
3条回答
Root(大扎)
2楼-- · 2019-02-11 02:59

or just use the command line flag

pip --disable-pip-version-check [normal stuff here]
查看更多
▲ chillily
3楼-- · 2019-02-11 03:01

Create a pip configuration file and set disable-pip-version-check to true

[global]
disable-pip-version-check = True

On many linux the default location for the pip configuration file is $HOME/.config/pip/pip.conf. Locations for Windows, macOS, and virtualenvs are too various to detail here. Refer to the docs:

https://pip.pypa.io/en/stable/user_guide/#config-file

查看更多
仙女界的扛把子
4楼-- · 2019-02-11 03:20

Another less intrusive and not directly documented but fully support way to disable the version check is to define:

export PIP_DISABLE_PIP_VERSION_CHECK=1
查看更多
登录 后发表回答