Hello community,
the package “reticulate” offers the possibility to call Python from R. I tried to run the basic_example.py (oemof-examples/oemof_examples/oemof.solph/v0.4.x/basic_example at master · oemof/oemof-examples · GitHub) via R. However, I always get the Error "Failed to create solver with name “CBC”.
Thanks in advance for your help.
Br,
Alex
Code:
library(reticulate)
use_python("C:/Anaconda", required = TRUE)
reticulate::py_config()
source_python(".../basic_example.py")
Console:
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.1
NOTE: Python version was forced by use_python function
> source_python(".../basic_example.py")
15:20:25-INFO-Path for logging: C:\Users\.oemof\log_files\oemof_example.log
15:20:25-INFO-Initialize the energy system
15:20:25-INFO-Create oemof objects
15:20:25-INFO-Optimise the energy system
15:20:26-INFO-Solve the optimization problem
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
15:20:26-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
Error in py_run_file_impl(file, local, convert) :
RuntimeError: Attempting to use an unavailable solver.
The SolverFactory was unable to create the solver "cbc"
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 "solve").
The original solver was created with the following parameters:
solver_io: lp
type: cbc
_args: ()
options: {}