1

I'm training a model on google colab, and im running this model on my local machine.

unfortunately, the environment variables on my local machine are very different from google colab's. I tried using conda on colab, but it's very difficult to use there.

is there an effective way to export environment variables from google colab and run them on local machine.

or the other way around to.

Thank you

slimboy
  • 1,633
  • 2
  • 22
  • 45

1 Answers1

1

Create a file named .env with this format:

KEY1=VALUE1
KEY2=VALUE2

Then upload the file and set the varialbles:

# upload .env file
from google.colab import files
files.upload()

env_list = ! cat .env
for v in env_list: 
    %set_env $v

You can also use python-dotenv initially mentioned in this question.

The approach mentioned in this question is probably the best to way to handle this setting environment variables in general, however, at least I couldn't find a simple way to use the result of a shell command in a magic command.

Mohammad Arvan
  • 603
  • 3
  • 11