Google合作使用kaggle,服务器版本1.5.6,客户端版本1.5.4,升级失败

Google colaboratory use kaggle, server version 1.5.6 , client version 1.5.4, failed to upgrade

我想在 google colaboratory 中使用 kaggle API。安装的客户端是1.5.4,服务器是1.5.6。 运行通过pip安装升级kaggle后,系统仍然调用1.5.4版本

我试过用pip安装和升级kaggle包。不起作用。我也尝试重新启动 session/runtime。

!pip install kaggle/pip install kaggle --upgrade
Requirement already up-to-date: kaggle in /usr/local/lib/python3.6/dist-packages (1.5.6)
Requirement already satisfied, skipping upgrade: requests in /usr/local/lib/python3.6/dist-packages (from kaggle) (2.21.0)
Requirement already satisfied, skipping upgrade: certifi in /usr/local/lib/python3.6/dist-packages (from kaggle) (2019.9.11)
Requirement already satisfied, skipping upgrade: tqdm in /usr/local/lib/python3.6/dist-packages (from kaggle) (4.28.1)
Requirement already satisfied, skipping upgrade: python-dateutil in /usr/local/lib/python3.6/dist-packages (from kaggle) (2.6.1)
Requirement already satisfied, skipping upgrade: python-slugify in /usr/local/lib/python3.6/dist-packages (from kaggle) (4.0.0)
Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from kaggle) (1.24.3)
Requirement already satisfied, skipping upgrade: six>=1.10 in /usr/local/lib/python3.6/dist-packages (from kaggle) (1.12.0)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle) (2.8)
Requirement already satisfied, skipping upgrade: text-unidecode>=1.3 in /usr/local/lib/python3.6/dist-packages (from python-slugify->kaggle) (1.3)
!kaggle -v
Kaggle API 1.5.4

啊,这确实是一个奇怪的状态。

修复:!pip install --upgrade --force-reinstall --no-deps kaggle

潜在问题:我们同时安装了 py2 和 py3 包,并且(由于历史原因)py2 包是第二个安装的。 kaggle 是 kaggle python 包安装的包装器;由于我们第二次执行 py2,因此 py2 包装器在 /usr/local/bin 中,并且恰好是旧版本。