66

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?

John Mee
  • 50,179
  • 34
  • 152
  • 186
personal_cloud
  • 3,943
  • 3
  • 28
  • 38
  • Why dont you just run the command 'pip install --upgrade pip'? You should be able to specify the version you want to upgrade to i.e 'pip install --upgrade pip==x.x.x' – Alan Kavanagh Sep 18 '17 at 22:08
  • @AK47 Hmm I guess what I want is the earliest pip version that was compatible with CentOS 7.3. Why wouldn't that be the version that shipped with CentOS 7.3? – personal_cloud Sep 18 '17 at 22:09
  • It has installed the most recently packaged version of `pip` in `yum`. Yum won't always have the latest version of pip. When you run pip it peeks online for the latest version and issues the warning where necessary. – John Mee Sep 18 '17 at 22:10
  • What do you mean that's compatible with CentOS 7.3? It wont be able to install a non compatible version surely? If you need a specific version the specify that in your command otherwise just upgrade to the latest.. I dont see why the version of pip is dependent on the underlying OS – Alan Kavanagh Sep 18 '17 at 22:10
  • Looking here: https://www.liquidweb.com/kb/how-to-install-pip-on-centos-7/ it says `yum -y install python-pip` should be good enough. – personal_cloud Sep 18 '17 at 22:11
  • 2
    There is nothing to fear here. You're overcooking it, but I understand, I do the same sort of thing routinely. You'll need to find a specific way to suppress the warning. Or learn to ignore it. – John Mee Sep 18 '17 at 22:12
  • *When you run pip it peeks online for the latest version and issues the warning where necessary.* That's exactly what I *don't* want it to do. I want a stable version that has been established to work with CentOS 7.3. I.e., the version that shipped in the extended packages of CentOS 7.3. – personal_cloud Sep 18 '17 at 22:12
  • This will install whatever version of pip is in the RH yum catalog on the OS. It doesnt necessarily mean it is the earliest compatible, I'd guess you could install pip v1.0.0 if you wanted.. why would you not want the latest version? – Alan Kavanagh Sep 18 '17 at 22:13
  • 1
    In that case you're going to need to learn to ignore the warning. This warning only goes away when you get the latest version of pip from pypi. The version packaged for centos will almost always be older than that. – ngoldbaum Sep 18 '17 at 22:14
  • 1
    I don't want pip going out and breaking things. I want a vagrant script that has known versions of everything. I don't want to just hack something that works now. I want to research what shipped with CentOS 7.3 and how that was made to work without the warning. If pip is printing a warning *anyway* then pip is broken and we can document that and move forward with ignoring the warning. – personal_cloud Sep 18 '17 at 22:15
  • 1
    @ngoldbaum Thank you. Please post as an answer and I will accept. Moving on. – personal_cloud Sep 18 '17 at 22:15
  • 1
    @AK47 "why would you not want the latest version?" because the latest version almost surely breaks something (in a way where there has not been sufficient time to develop workarounds yet). I want the version that was accepted by RH, Ubuntu, etc. – personal_cloud Sep 20 '17 at 19:54
  • @personal_cloud thats grand - hope you got this sorted – Alan Kavanagh Sep 20 '17 at 19:55
  • @AK47 Indeed, for the pips that ship with up to CentOS 7.3, I feel we have a good enough solution. I'm sure that the latest pip removes the `disable-pip-version-check` feature and we can cross that bridge when the workarounds for that have been developed. – personal_cloud Sep 20 '17 at 20:03
  • 3
    My prediction proved spectacularly correct. Pip 21 [breaks all Python < 3.6 completely](https://stackoverflow.com/questions/65869296/installing-pip-is-not-working-in-python-3-6/). – personal_cloud Mar 08 '21 at 00:11
  • @AK47 In my case I do not want to be distracted by message that is not helpful. Ansible script takes care of updating my software, including pip. – reducing activity Mar 13 '22 at 14:48

6 Answers6

98

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

John Mee
  • 50,179
  • 34
  • 152
  • 186
  • 9
    instead of editing the file, you can run `pip config set global.disable-pip-version-check true` – jnnnnn Nov 16 '20 at 06:06
51

or just use the command line flag

pip --disable-pip-version-check [normal stuff here]
pushkin
  • 9,575
  • 15
  • 51
  • 95
Tim Hallbeck
  • 655
  • 5
  • 7
36

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
sorin
  • 161,544
  • 178
  • 535
  • 806
26

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

ARG PIP_DISABLE_PIP_VERSION_CHECK=1
ARG PIP_NO_CACHE_DIR=1

RUN pip3 install -r requirements.txt
# ...
Levon
  • 10,408
  • 4
  • 47
  • 42
  • 1
    I prefer to `pip install --upgrade pip` to ensure the latest `pip` is used rather than disabling the version check. – phoenix Oct 30 '20 at 14:31
  • 3
    If your image was used in a FROM statement in another dockerfile, wouldn't that mean that the environment variables would still exists in that image? That would lead to surprising behavior when using `pip install` down the line. I guess I prefer not to change persistent state in a dockerfile so I would recommend using the command line arguments instead: `RUN pip install --disable-pip-version-check --no-cache-dir -r requirements.txt` – iron9 Jan 07 '21 at 13:47
  • 2
    @iron9 yes that is correct, however you can use `ARG` instead of `ENV` to make the env vars available only during build, not in the actual image. e.g. `ARG PIP_NO_CACHE_DIR=1` – Andy Madge May 18 '22 at 11:29
4

Modify your pip configuration with the command

pip config set global.disable-pip-version-check true
jnnnnn
  • 3,889
  • 32
  • 37
0

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

personal_cloud
  • 3,943
  • 3
  • 28
  • 38
ayanamist
  • 1,035
  • 3
  • 12
  • 20