I am trying to install theano in Google Colab for testing. I have installed virtualenv and created an environment:
!pip3 install virtualenv
!vir
Basically each ! command runs in its own shell, and Colaboratory does not know the environment changed
I figured out a workaround for this. Since each shell is temporary, we stitch the environment activation command and the command to be executed in environment.
So after you do
!pip3 install virtualenv
!virtualenv theanoEnv
you can install theano in the environment by
!source /content/theanoEnv/bin/activate; pip3 install theano
Since the environment contents are stored on disk in theanoEnv directory, it is preserved. But you need to activate it for each new shell. For every command you need to run in the environment, simply prefix it with
!source /content/theanoEnv/bin/activate;
For example, to get a list of installed python packages (i.e. to run pip3 list) in environment, run:
!source /content/theanoEnv/bin/activate; pip3 list
You can stitch multiple commands this way: (all of them will be executed in the same shell)
!source /content/theanoEnv/bin/activate; COMMAND1; COMMAND2; COMMAND3
You can check my notebook on Colab here.