Getting Keyerror when exporting python path variable

Shwait Kumar :

Im trying to run a pre trained model in tensorflow. When i try to run the following command in Jupytar i get an error:

import os
os.environ['PYTHONPATH'] = "{}/content/obj_detect_api/models:/content/obj_detect_api/models/research:/content/obj_detect_api/models/research/slim".format(os.environ['PYTHONPATH'])

The error I'm getting is :

    KeyError                                  Traceback (most recent call last)
<ipython-input-5-f5b49a56ddb2> in <module>
      1 import os
----> 2 os.environ['PYTHONPATH'] = "{}/content/obj_detect_api/models:/content/obj_detect_api/models/research:/content/obj_detect_api/models/research/slim".format(os.environ['PYTHONPATH'])

~/opt/anaconda3/lib/python3.7/os.py in __getitem__(self, key)
    677         except KeyError:
    678             # raise KeyError with the original key value
--> 679             raise KeyError(key) from None
    680         return self.decodevalue(value)
    681 

KeyError: 'PYTHONPATH'
kederrac :

to set an environment variable from jupyter you can use:

%env PYTHONPATH=MY_VALUE

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=405486&siteId=1