'OSError: Could not find kaggle.json. Make sure it's located in C:\Users\Lior\.kaggle. Or use the environment method

I have a similar problem as: Kaggle API issue "Could not find kaggle.json. Make sure it's located in......"

I have the same error when I type kaggle competitions download -c spaceship-titanic

But in my case the folder ".kaggle/" is actually empty. So I assume I downloded kaggle api incorrectly, how I download it correctly?

Things I have tried acccording to https://github.com/Kaggle/kaggle-api

pip install kaggle, pip install --user kaggle, sudo pip install kaggle

The first two compiled, but didnot create the kaggle.json file.

The third didnot compiled and it said sudo command not found.



Solution 1:[1]

Sample photo for finding the accounts page

Sample photo for finding the accounts page

Solution 2:[2]

you can use "requests" library and making a request on the django view for this page.

import requests

def my_view(request):
    r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
    context = {
         'data': r.json()
    }
    return render(request, 'my_html.html', context)

Solution 3:[3]

You can simply use JavaScript fetch API like following:

page.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My Title</title>
</head>
<body>
<h1 id="msg"></h1>
<script>
  var url = 'http://127.0.0.1:8080/message';
  fetch(url).then(
    response => response.json()
  ).then(function(data) {
    document.getElementById("msg").textContent = data['message'];
  });
</script>
</body>
</html>

views.html

from django.shortcuts import render
from django.http import JsonResponse


def index(request):
    return render(request, "index.html")


def message(request):    
    return JsonResponse({"message": "Hello World!"})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Whereismywall
Solution 2 elkhayyat
Solution 3 Ahtisham