Help us understand the problem. What is going on with this article?

kaggleを始めるなら入れておこう。kaggleコマンドをインストールするぞ

More than 1 year has passed since last update.

kaggleやっていこう、ということでdata Downloadしようとしたところ以下のようなコマンドを発見。

kaggle competitions download -c competition-name

なにやら一括ダウンロードできたり便利そうな雰囲気を感じる、とりあえず使えるようにしたい。

(環境構築)

とりあえずまっさらな状態で試したかったのでvenvで環境を作ってactivate。

python3 -m venv kaggle-venv

# activate
source kaggle-venv/bin/activate

インストール

基本的には公式のREADMEにそのまま従う。

pip3 install kaggle

api keyの発行と設定

kaggleのマイページからapi keyを発行する。
https://www.kaggle.com/

[Sign in] -> [My Account] -> [Create New API Token]
とすると、kaggle.jsonがダウンロードされる。
以下のコマンドで~./kaggle以下に移動させ、アクセス権限を変更する。

mkdir ~/.kaggle
mv ~/Downloads/kaggle.json ~/.kaggle
chmod 600 ~/.kaggle/kaggle.json

実行

kaggle competitions list

とすると、コンペ一覧が表示されるはずだが、エラー。

Traceback (most recent call last):
  File "/Users/name/kaggle-venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws.require(__requires__)
  File "/Users/name/kaggle-venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 892, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/name/kaggle-venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 783, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (urllib3 1.23 (/Users/name/kaggle-venv/lib/python3.6/site-packages), Requirement.parse('urllib3<1.23,>=1.21.1'), {'requests'})

Requirement.parse('urllib3<1.23,>=1.21.1')
と言われているので、urllib3のバージョンの問題のようである。

pip3 freeze

certifi==2018.4.16
chardet==3.0.4
idna==2.6
kaggle==1.3.9
python-dateutil==2.7.3
requests==2.18.4
six==1.11.0
tqdm==4.23.4
urllib3==1.23 # oh no

1.23はだめなようなので、バージョン指定して再インストール

pip3 uninstall urllib3
pip3 install urllib3==1.22

気を取り直して再実行。

kaggle competitions list

ref                                             deadline             category            reward  teamCount  userHasEntered  
----------------------------------------------  -------------------  ---------------  ---------  ---------  --------------  
imagenet-object-detection-challenge             2029-12-31 07:00:00  Research         Knowledge          0           False  
imagenet-object-detection-from-video-challenge  2029-12-31 07:00:00  Research         Knowledge          0           False  
imagenet-object-localization-challenge          2029-12-31 07:00:00  Research         Knowledge         15           False  
titanic                                         2020-04-07 00:00:00  Getting Started  Knowledge      11343           False  
house-prices-advanced-regression-techniques     2020-03-01 23:59:00  Getting Started  Knowledge       5456           False  
digit-recognizer                                2020-01-07 00:00:00  Getting Started  Knowledge       2636           False  
competitive-data-science-predict-future-sales   2019-01-01 23:59:00  Playground           Kudos        694           False  
home-credit-default-risk                        2018-08-29 23:59:00  Featured           $70,000       2085           False  
trackml-particle-identification                 2018-08-13 23:59:00  Featured           $25,000        389           False  
...

お疲れ様でした。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした