如何抑制pip升级警告?

新手上路,请多包涵

我的 pip 版本已关闭——每个 pip 命令都在说:

 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.

而且我不喜欢这里给出的答案: How can I get rid of this warning to upgrade from pip? 因为他们都希望 pip 与 RH 版本不同步。

所以我尝试使用这个 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

但后来我得到了:

 ==> 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.

所以看来我使用了错误的命令来安装 pip 。什么是正确的命令使用?

原文由 personal_cloud 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.1k
2 个回答

有很多选择(2021 更新)…

使用命令行标志

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

从命令行配置 pip

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

设置环境变量

export PIP_DISABLE_PIP_VERSION_CHECK=1

使用配置文件

创建一个 pip 配置文件并将 disable-pip-version-check 设置为 true

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

在许多 Linux 上,pip 配置文件的默认位置是 $HOME/.config/pip/pip.conf 。 Windows、macOS 和 virtualenvs 的位置太多了,这里无法详细说明。请参阅文档:

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

原文由 John Mee 发布,翻译遵循 CC BY-SA 4.0 许可协议

或者只使用命令行标志

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

原文由 Tim Hallbeck 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题