pythongoogle-colaboratorykagglerequirements.txt

How can I get the requirements.txt file on Colab or Kaggle notebook?


I finished my project on Kaggle but I want to add requirements file how can I do it

I want to do it directly from Kaggle or colab file


Solution

  • In Google colab, to get an initial colab environment (set of modules that already installed by Google colab. You can use it without any further import) , you can try this :

    # to get packages initially installed in colab or in other word, the colab environment
    !pip3 freeze > requirements.txt  
    

    For the code above, the requirements.txt file will appear in the content section of your Google colab (will be in the path named : ā€˜/content/ā€˜) Or, in case that what you want is the imported module, not a colab environment. What you can do is :

    # get list of all imported modules 
    import sys
    print(sys.modules.keys())
    

    Moreover, for the requirements.txt in kaggle, you can take a quick look at the comment below your question section. The reference link provided by Ali Ent was very clear

    Hope this help !