title: R - Reticulate - Python - Pyomo - Failed to create solver [WinError 6]
body: <p>I tried to run the following code via R with reticulate and pyomo based on the solver &quot;cbc&quot;. The Python-code is working if I execute the code independently of R. Executing the code in R with the package &quot;reticulate&quot; doesn't work.</p>
  <p>Information about the Python-code: A Simple Concrete Pyomo Model - <a href="https://pyomo.readthedocs.io/en/stable/pyomo_overview/simple_examples.html" rel="nofollow noreferrer">https://pyomo.readthedocs.io/en/stable/pyomo_overview/simple_examples.html</a></p>
  <p>Code in Python:</p>
  <pre class="lang-py prettyprint-override"><code>from pyomo.environ import *
  
  import pyutilib.subprocess.GlobalData
  pyutilib.subprocess.GlobalData.DEFINE_SIGNAL_HANDLERS_DEFAULT = False
  
  model = ConcreteModel()
  
  model.x = Var([1,2], domain=NonNegativeReals)
  
  model.OBJ = Objective(expr = 2*model.x[1] + 3*model.x[2])
  
  model.Constraint1 = Constraint(expr = 3*model.x[1] + 4*model.x[2] &gt;= 1)
  
  opt = SolverFactory('cbc')
  opt.solve(model)
  </code></pre>
  <p>Code in R:</p>
  <pre class="lang-r prettyprint-override"><code>library(&quot;reticulate&quot;)
  
  use_python(&quot;C:/Anaconda&quot;)
  setwd(&quot;C:/Users/SimpleConcretePyomoModel&quot;)
  source_python(&quot;C:/Users/SimpleConcretePyomoModel/SimpleConcretePyomoModel.py&quot;)
  </code></pre>
  <p>Error in R</p>
  <pre class="lang-none prettyprint-override"><code>Error in py_run_file_impl(file, local, convert) : 
    RuntimeError: Attempting to use an unavailable solver.
  
  The SolverFactory was unable to create the solver &quot;cbc&quot;
  and returned an UnknownSolver object.  This error is raised at the point
  where the UnknownSolver object was used as if it were valid (by calling
  method &quot;solve&quot;).
  
  The original solver was created with the following parameters:
      type: cbc
      _args: ()
      options: {}
  WARNING: Failed to create solver with name 'cbc': Could not execute the
      command: 'C:\Program Files\cbc-win64\cbc.exe -stop'
          Error message: [WinError 6] Das Handle ist ungültig
  </code></pre>
  <p>Additional information:</p>
  <pre class="lang-none prettyprint-override"><code>python:             C:/Anaconda/python.exe
  libpython:          C:/Anaconda/python38.dll
  pythonhome:         C:/Anaconda
  version:            3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
  Architecture:       64bit
  numpy:              C:/Anaconda/Lib/site-packages/numpy
  numpy_version:      1.20.3
  pyomo_version:      5.7.2
  reticulate_version: 1.20
  cbc_version:        2.10.3
  RStudio_version:    1.4.1717
  Spyder_version:     5.0.5
  </code></pre>