Setting environment variables in Google Colab with %env doesn't seem to properly expand existing environment variables when prefixed by $:
> !echo $PATH
/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin:/opt/bin
> %env PATH=$PATH
env: PATH=$PATH
> !echo PATH
PATH
I don't think setting environment variables with !export works either. Does anyone know a way around this?
This worked for me
!echo $PATH
OLD_ENV_PATH = %env PATH
%env PATH=$OLD_ENV_PATH:/test
!echo $PATH
%env uses python expansion, so you need to store value for env variable in some python variable, and then set env var referencing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With