Best way to copy python environment of Google colab

Viewed 974

I have a code which was developed on Google colab and now I want to run it on local machine or on a server. The problem is my code has got a lot of dependencies and its getting difficult to prepare an virtual / conda environment. The code is working perfectly on colab. So is there any way so that I can have an image of that environment so its easier for me to run it wherever I want

1 Answers

You can run this command: !pip freeze and you will get all packages installed and their versions:

enter image description here

you can copy paste this to your local machine into a requirements.txt, or you can download this file with this commands:

  1. Execute in one cell !pip freeze >> requirements.txt
  2. Go to the left panel : enter image description here
  3. Right click on file created, and select download

enter image description here

the last step is create the environment, yoy can use conda or virtenv. Use pip with this command: pip install -r requirements.txt

Related