Forums

Pyomo optimization

I would like to use pyomo to do linear optimization. I installed the pyomo package using pip3 without problem. I can import the environment without error, but when I try to run pyomo commands I get a NameError. I also need to load a solver such as CBC to do optimization. Is this possible using pythonanywhere?

NameError means that you're trying to access a variable that you have not defined. Make sure that you are defining variables before you use them.

We do not have cbc installed. I have raised a ticket to include it the next time we create a system image (probably in a few months).

Hi! Is cbc installed now?

I think when we came to install it, we could not work out what the original poster meant by CBC, so we had nothing to install. Send us a link to the library and we'll see what we can do for the next system image.

Hi,

I would like to use CBC solver, too! --> https://github.com/coin-or/Cbc Is it possible in the meantime? If yes, could you teach me how to install it?

I had used GLPK solver so far but failed with a certain program leading to infeasible solutions. I had someone else try the same notebook and run it with CBC and it works on a local host... I would therefore like use CBC in pythonanywhere!!!

Thanks and regards, Marcus

Not sure if it would work, but according to readme in the repo you may try to install it with conda. See https://help.pythonanywhere.com/pages/conda/ how to use conda on PythonAnywhere.

Unfortunately it did not work out... we installed a conda venv and cbc, but when calling cbc a "bus error" is returned. CBC bus error on conda venv

Second issue: How can we run the python kernel of the conda environment in the jupyter notebook?

All in all it'se seems to be a big hassle to find a solution for the above topics... whereas on a local linux machine it worked easily right away:

CBC on linux

This is likely because on PythonAnywhere your user does not have sudo priviledges