kaggle.json没找到

背景:

在使用jupyter运行fastbook第九章中代码时报了个错误:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
 in 
      1 #hide
      2 from fastbook import *
----> 3 from kaggle import api
      4 from pandas.api.types import is_string_dtype, is_numeric_dtype, is_categorical_dtype
      5 from fastai.tabular.all import *

~/.local/lib/python3.6/site-packages/kaggle/__init__.py in 
     21 
     22 api = KaggleApi(ApiClient())
---> 23 api.authenticate()

~/.local/lib/python3.6/site-packages/kaggle/api/kaggle_api_extended.py in authenticate(self)
    164                 raise IOError('Could not find {}. Make sure it\'s located in'
    165                               ' {}. Or use the environment method.'.format(
--> 166                                   self.config_file, self.config_dir))
    167 
    168         # Step 3: load into configuration!

OSError: Could not find kaggle.json. Make sure it's located in /home/tianlang/.kaggle. Or use the environment method.

解决方法:

1.获取kaggle.json

访问https://www.kaggle.com/注册登录后点击account也可以直接访问链接https://www.kaggle.com/你的kaggle用户名/account 

kaggle.json没找到_第1张图片

然后点击:

kaggle.json没找到_第2张图片

然后就有个名称为kaggle.json的文件下载下来了.

2.把kaggle.json文件放到报错信息提示的目录.一般在~/.kaggle/下.

问题解决!为了安全起见也可以修改下kaggle.json文件的访问权限

chmod 600 ~/.kaggle/kaggle.json

这样其他用户使用了这台电脑就看不到你的kaggle token了.

Kaggle API的错误信息提示还是挺友好的,你觉得呢?

 

你可能感兴趣的:(日志,fastai,linux,ubuntu,python,kaggle,机器学习)