Basically, if you want to use the Kaggle python API (the solution provided by @minh-triet is for the command line not for python) you have to do the following:
import kaggle
kaggle.api.authenticate()
kaggle.api.dataset_download_files('The_name_of_the_dataset', path='the_path_you_want_to_download_the_files_to', unzip=True)
I hope this helps.
Answer from Yannis on Stack Overflowpython - Kaggle datasets into jupyter notebook - Stack Overflow
Trouble importing kaggle datasets
How to connect kaggle notebook to VScode, so that I can take advantage of the intelisense that VScode offers?
New to Kaggle, do you all actually use Kaggle notebooks?
Videos
Basically, if you want to use the Kaggle python API (the solution provided by @minh-triet is for the command line not for python) you have to do the following:
import kaggle
kaggle.api.authenticate()
kaggle.api.dataset_download_files('The_name_of_the_dataset', path='the_path_you_want_to_download_the_files_to', unzip=True)
I hope this helps.
kaggle api key and usersame is available on kaggle profile page and dataset download link is available on dataset details page on kaggle
#Set the enviroment variables
import os
os.environ['KAGGLE_USERNAME'] = "xxxx"
os.environ['KAGGLE_KEY'] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
!kaggle competitions download -c dogs-vs-cats-redux-kernels-edition
I think that the name of the competition is wrong. Try:
from kaggle.api.kaggle_api_extended import KaggleApi
api = KaggleApi('copy and paste kaggle.json content here')
api.authenticate()
files = api.competition_download_files("two-sigma-financial-news")
While looking through the source code, I found this class. I think the notebook doesn't auto authenticate when you call KaggleApi(), hence you need to call the authenticate function on the API to connect to the Kaggle API.
Try:
api = KaggleApi()
api.authenticate()
I was able to connect and download the samples after this call.