Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16981

How do I set environment variables in Google Colab?

$
0
0

On my local computer, I can simply go into "System Properties -> Environment Variables" and add a new variable with its value in user variables.

Then, I can retrieve this value by using this in Python:

import osos.environ["VAR_NAME"]

However, I just recently started using Google Colab, and it seems it's not able to detect the environment variable, as it gives me this error:

---------------------------------------------------------------------------KeyError                                  Traceback (most recent call last)<ipython-input-36-28128554cf91> in <module>()      1 import os----> 2 os.environ["REDDIT_NAME"]/usr/lib/python3.7/os.py in __getitem__(self, key)    679         except KeyError:    680             # raise KeyError with the original key value--> 681             raise KeyError(key) from None    682         return self.decodevalue(value)    683 KeyError: 'REDDIT_NAME'

How should I go about so that Google Colab can detect my user environment variables? Is there a specific path I need to modify?

Thanks.


Viewing all articles
Browse latest Browse all 16981

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>