通过API下载kaggle数据集

1.新建一个环境

打开Anaconda Navigator,新建一个环境。

2.安装kaggle库

在Anaconda Prompt激活新建的环境,并安装kaggle库。

(base) C:\Users\Winky>conda activate toolwear
(toolwear) C:\Users\Winky>pip install kaggle -i https://pypi.tuna.tsinghua.edu.cn/simple/
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting kaggle
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/25/fc/6457512e32b677ff41c85d3f29a8f443626cf18b6113700f162171b2608c/kaggle-1.6.14.tar.gz (82 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.1/82.1 kB 1.1 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting six>=1.10 (from kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting certifi>=2023.7.22 (from kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ba/06/a07f096c664aeb9f01624f858c3add0a4e913d6c96257acb4fce61e7de14/certifi-2024.2.2-py3-none-any.whl (163 kB)
Collecting python-dateutil (from kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Collecting requests (from kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c3/20/748e38b466e0819491f0ce6e90ebe4184966ee304fe483e2c414b0f4ef07/requests-2.32.2-py3-none-any.whl (63 kB)
Collecting tqdm (from kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/18/eb/fdb7eb9e48b7b02554e1664afd3bd3f117f6b6d6c5881438a0b055554f9b/tqdm-4.66.4-py3-none-any.whl (78 kB)
Collecting python-slugify (from kaggle)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a4/62/02da182e544a51a5c3ccf4b03ab79df279f9c60c5e82d5e8bec7ca26ac11/python_slugify-8.0.4-py2.py3-none-any.whl (10 kB)
Collecting urllib3 (from kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a2/73/a68704750a7679d0b6d3ad7aa8d4da8e14e151ae82e6fee774e6e0d05ec8/urllib3-2.2.1-py3-none-any.whl (121 kB)
Collecting bleach (from kaggle)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ea/63/da7237f805089ecc28a3f36bca6a21c31fcbc2eb380f3b8f1be3312abd14/bleach-6.1.0-py3-none-any.whl (162 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 162.8/162.8 kB 4.8 MB/s eta 0:00:00
Collecting webencodings (from bleach->kaggle)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Collecting text-unidecode>=1.3 (from python-slugify->kaggle)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/a5/c0b6468d3824fe3fde30dbb5e1f687b291608f9473681bbf7dabbf5a87d7/text_unidecode-1.3-py2.py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.2/78.2 kB 4.2 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2 (from requests->kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/db/fb/d29e343e7c57bbf1231275939f6e75eb740cd47a9d7cb2c52ffeb62ef869/charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl (99 kB)
Collecting idna<4,>=2.5 (from requests->kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/e5/3e/741d8c82801c347547f8a2a06aa57dbb1992be9e948df2ea0eda2c8b79e8/idna-3.7-py3-none-any.whl (66 kB)
Collecting colorama (from tqdm->kaggle)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Building wheels for collected packages: kaggle
  Building wheel for kaggle (setup.py) ... done
  Created wheel for kaggle: filename=kaggle-1.6.14-py3-none-any.whl size=105128 sha256=3c50fb471a7e6a9b392cfd5e3bab839fa93baed148a0aeee2421e6296ce66951
  Stored in directory: c:\users\吴伊晴\appdata\local\pip\cache\wheels\fb\97\67\a25fb181a2e051c3fa20aa1e435c4eee4b1142e27857e1c4f9
Successfully built kaggle
Installing collected packages: webencodings, text-unidecode, urllib3, six, python-slugify, idna, colorama, charset-normalizer, certifi, tqdm, requests, python-dateutil, bleach, kaggle
Successfully installed bleach-6.1.0 certifi-2024.2.2 charset-normalizer-3.3.2 colorama-0.4.6 idna-3.7 kaggle-1.6.14 python-dateutil-2.9.0.post0 python-slugify-8.0.4 requests-2.32.2 six-1.16.0 text-unidecode-1.3 tqdm-4.66.4 urllib3-2.2.1 webencodings-0.5.1

3.Create New API Token

进入kaggle官网,点击右上方的头像,再点击“Settings”,进入设置界面。

 找到API栏,选择Create New API Token。

Are you sure?
你确定吗?
Generating a new token will automatically expire any previous key.
生成新令牌将自动使以前的任何密钥过期。

选择继续

之后得到一个自动下载的.json文件 

 

4.将kaggle.json文件放入.kaggle文件夹 

.kaggle文件路径“C:\Users\Winky\.kaggle”,将kaggle.json剪切过去。

5. Copy API command and download

kaggle kernels output koheimuramatsu/cnc-milling-machine-tool-wear-detection -p /path/to/dest

 将“/path/to/dest”替换为我想该文件放的路径

(base) C:\Users\Winky>kaggle kernels output koheimuramatsu/cnc-milling-machine-tool-wear-detection -p D:\toolwear
Warning: Looks like you're using an outdated API Version, please consider updating (server 1.6.14 / client 1.6.12)
Kernel log downloaded to D:\toolwear\cnc-milling-machine-tool-wear-detection.log

成功下载 

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值