Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set environment variables in Google's Colaboratory?

I am running some Python scripts in Google's Colaboratory platform. Now, I need to set some environment variables of the system. Like the following shows:

!export PATH=drive/app/tf-models-fork/research;drive/app/tf-models-fork/research/object_detection;drive/app/tf-models-fork/research/slim;$PATH

I tried to add the location to the variable PATH. However, I am getting the following errors:

/bin/sh: 1: drive/app/tf-models-fork/research/object_detection: Permission denied
/bin/sh: 1: drive/app/tf-models-fork/research/slim: Permission denied
/bin/sh: 1: drive/app/tf-models-fork/research: Permission denied

Is there any way to set the environment variables in this platform?

like image 221
ZQ Hu Avatar asked Apr 06 '18 02:04

ZQ Hu


People also ask

Is there a variable Explorer in Google Colab?

Colab now has a variable inspector to give you more insights into what your code is doing while executing. More information on this and the status bar at github.com/googlecolab/co….


1 Answers

I normally set the PATH with os.environ, like this:

import os
os.environ['PATH'] += ":/usr/local/go/bin"
like image 127
korakot Avatar answered Oct 20 '22 12:10

korakot