pyomo + reticulate error 6 the handle is invalid

I can not say I understand this problem entirely, however it is a very interesting one to research, mainly because I got a different error message

TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object

and while I got the error every time I ran py_run_file("test.py") in a new r session, by the second run there was no error.

That being said I believe it is related to this issue: https://github.com/PyUtilib/pyutilib/issues/31

I didn't face any problem after adding the two lines :

import pyutilib.subprocess.GlobalData
pyutilib.subprocess.GlobalData.DEFINE_SIGNAL_HANDLERS_DEFAULT = False

in the python script before invoking the solver.

Hope this helps


If you can execute the python version, try to r session with administrative right with the following code

library("reticulate")


##-- your directory containing 'diet.py' and 'diet.dat'
setwd("D:/project/Dropbox/lectures/2104xxx scg_opt/src/02"")



##-- execute code
a <- py_run_file("diet.py",local=T)
a$results