Saturday, May 30, 2020

Installing Pyomo on colab by google

Google has a nice online environment (https://colab.research.google.com/) to run Python code. So let's try Pyomo...

The installation instructions are simple:


 The first step was easy:


However, the second step was unsuccessful:


This is of course a little bit disappointing. I am not aware of a workaround.

2 comments:

  1. Hi Erwin,

    There's an open issue in the Pyomo repo about this (trying to pip install pyomo-extras) - https://stackoverflow.com/a/55764943/4540852. A workaround can be to conda install the package instead.

    As Google Colab doesn't include Conda, we have to install it first. I found this link https://stackoverflow.com/a/50302183/4540852 and used the same idea:

    1) First, install a Miniconda distribution.
    !wget -c https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
    !chmod +x Miniconda3-latest-Linux-x86_64.sh
    !bash ./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local

    2) then add to the environment:
    import sys
    sys.path.append('/usr/local/lib/python3.7/site-packages/')

    3) conda install pyomo and pyomo.extras.
    !conda install -c conda-forge pyomo
    !conda install -c conda-forge pyomo.extras

    This code worked with no errors in a Google Colab environment, those command could be at the notebook's first cell in order to install pyomo & pyomo-extras. I hope this helps, feel free to copy the Notebook from this link: https://gist.github.com/dhasson/ad2944cf978c9ce22ceb2bc530c85f37

    ReplyDelete
  2. Great, thanks. I think the installation instructions have changed and references to install-extras have been removed.

    ReplyDelete