How to suppress pip upgrade warning?

PythonPip

Python Problem Overview


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: https://stackoverflow.com/questions/36410756/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 Solutions


Solution 1 - Python

There are many options (2021 update)...

Use a command line flag

pip <command> --disable-pip-version-check [options]

Configure pip from the command line

pip config set global.disable-pip-version-check true

Set an environment variable

export PIP_DISABLE_PIP_VERSION_CHECK=1

Use a config file

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

Solution 2 - Python

or just use the command line flag

pip --disable-pip-version-check [normal stuff here]

Solution 3 - Python

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

Solution 4 - Python

Just adding to @sorin's answer

inside Dockerfile add these 2 lines to disable both pip version check and cache.

FROM python:3.6.10

ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1

RUN pip3 install -r requirements.txt
# ...

Solution 5 - Python

Modify your pip configuration with the command

pip config set global.disable-pip-version-check true

Solution 6 - Python

It seems answers above is invalid on pip 20.3.4

Use pip <command> --no-python-version-warning [options] temporarily

Or pip config --no-python-version-warning --global set global.no-python-version-warning true permanently

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionpersonal_cloudView Question on Stackoverflow
Solution 1 - PythonJohn MeeView Answer on Stackoverflow
Solution 2 - PythonTim HallbeckView Answer on Stackoverflow
Solution 3 - PythonsorinView Answer on Stackoverflow
Solution 4 - PythonLevonView Answer on Stackoverflow
Solution 5 - PythonjnnnnnView Answer on Stackoverflow
Solution 6 - PythonayanamistView Answer on Stackoverflow