2
$\begingroup$

I have recently tried to use the CPLEX solver to solve one of my Pyomo models. I first installed the community version that is available:https://pypi.org/project/cplex/ using pip.

However, I am trying to switch to the academic license of the solver and I am facing several problems. The main issue is that when I call SolverFactory('cplex') I get the following error:

pyomo.common.errors.ApplicationError: No executable found for solver 'cplex'

If I use "cplex_direct" the solver works as expected but the community edition is used instead. I also tried running the setup.py script available at /Applications/CPLEX_Studio221/cplex/python/3.9/x86-64_osx but I could not fix the problem. How do I resolve this?

$\endgroup$

2 Answers 2

2
$\begingroup$

One of the following will probably solve the problem:

  1. Add Cplex to the system Path in your laptop

  2. add executable= to the Solver factory:

    solver = SolverFactory(cplex, executable='C:/Program Files/...')

$\endgroup$
1
  • $\begingroup$ Doesn't your answer refers to Windows specifically? I tried a similar approach on MacOS but it did not work. Can you elaborate more if you are familiar with how I can do that? $\endgroup$
    – Pia MiA
    Commented Nov 16, 2022 at 17:33
1
$\begingroup$

To run CPLEX on MacOS use the code:

    solver = SolverFactory('cplex', executable = '/Applications/CPLEX_Studio2211/cplex/bin/x86-64_osx/cplex')
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.