You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is for the environment method mentioned in here:
IOError: Could not find kaggle.json. Make sure it's located in /root/.kaggle. Or use the environment method.
I read your logic for reading environment variables in case ~/.kaggle/kaggle.json does not exist. I suggest you first load the environments variable using python-dotenv before using os.environ to extract the variable names that start with KAGGLE_.
The moment someone imports kaggle in their project, your __init__.py script is immediately executed, which, in turn, attempts to read the environment variables before the .env is even loaded. This means the line if key.startwith("KAGGLE_"): in theread_config_environment() method will always return False even if the developer already has an .env file with the correct varaibles.
Here's is a snippet of my suggestion for /kaggle/__init_.py:
# coding=utf-8importdotenv# Load environment variables for the read_config_environment() methoddotenv.load_dotenv()
from __future__ importabsolute_importfromkaggle.api.kaggle_api_extendedimportKaggleApifromkaggle.api_clientimportApiClientapi=KaggleApi(ApiClient())
api.authenticate()
The text was updated successfully, but these errors were encountered:
This is for the environment method mentioned in here:
I read your logic for reading environment variables in case
~/.kaggle/kaggle.json
does not exist. I suggest you first load the environments variable usingpython-dotenv
before usingos.environ
to extract the variable names that start withKAGGLE_
.The moment someone imports
kaggle
in their project, your__init__.py
script is immediately executed, which, in turn, attempts to read the environment variables before the.env
is even loaded. This means the lineif key.startwith("KAGGLE_"):
in theread_config_environment()
method will always returnFalse
even if the developer already has an.env
file with the correct varaibles.Here's is a snippet of my suggestion for
/kaggle/__init_.py
:The text was updated successfully, but these errors were encountered: