How do I import knitro into Python?

If you are having trouble importing knitro in Python, try the following in the Terminal (for this example, we also recommend using Python 3 module instead of the system default Python 2):

module load anaconda3 knitro

Append the path to knitro python so that python knows about knitro executable:

export PYTHONPATH=$PYTHONPATH:/software/non-free/knitro-12.1.1/knitro-12.1.1-Linux-64/examples/Python

Then you should be able to import knitro library in the Python console:

>>> import knitro

Note that the export command only applies to an active session so you would have to reload anaconda 3 and knitro modules and export the path every time you login to the yens or get disconnected.