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

非 Y 不嫁゛ 提交于 2019-12-01 05:11:42
Korakot Chaovavanich

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

import os
os.environ['PATH'] += ":/usr/local/go/bin"

For PATH environment variables, such as PYTHONPATH, I use sys.path.insert or sys.path.append.

You have these 2 options because sys.path is a list of strings (paths), thus you can either insert or append more strings.

For example,

If you want to insert a new path at index 0:

import sys
sys.path.insert(0,'/path/to/folder')

If you want to append a new path:

import sys
sys.path.append('/path/to/folder')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!