Reputation: 53
i am trying to implement a simple optimization problem in pyomo using cplex solver in UBUNTU. My program runs fine with glpk solver. Now i installed cplex, docplex using conda but got following error warning while solving. it couldnot locate cplex executable file
WARNING: Could not locate the 'cplex' executable, which is required for solver
ERROR: Unexpected exception while running model: No executable found for solver 'cplex' errorcode: 1
retval: None
i added below lines in .bashrc file but still could'nt get the result
export PATH="/home/yash/anaconda3/envs/my_env/lib/python3.6/site-packages/docplex:$PATH"
export PATH="/home/yash/anaconda3/envs/my_env/lib/python3.6/site-packages/cplex:$PATH"
Upvotes: 1
Views: 8285
Reputation: 4465
From the source code, we can see that pyomo
comes with several CPLEX solver interfaces. One of these interfaces requires that the cplex "executable (i.e., the CPLEX "interactive") is in your PATH
and I believe this is the default. However, when you install the anaconda cplex
package you do not get this executable. This partially explains the error message you are getting.
If you want to use the CPLEXSHELL
interface (i.e., the one that shells out to the CPLEX interactive), then you'll need to install one of the IBM ILOG CPLEX Optimization Studio editions (e.g., the free Community Edition) and then update your PATH
to point at COS_INSTALL_DIR/cplex/bin/PLATFORM
(where COS_INSTALL_DIR
is the location you installed CPLEX Optimization Studio and PLATFORM
is the platform you installed on (e.g., x86-64_linux
)).
Alternatively, and I think this is what you're really trying to do, if you want to use the pyomo
interface that connects to the CPLEX Python API, then you just need to fix your environment variables.
Instead of:
export PATH="/home/yash/anaconda3/envs/my_env/lib/python3.6/site-packages/cplex:$PATH"
Try using:
export PYTHONPATH="/home/yash/anaconda3/envs/my_env/lib/python3.6/site-packages:$PYTHONPATH"
Also, it's not entirely clear, but it almost looks like you've installed the cplex
package into a Python virtual environment (aka, a virtualenv). If that is the case, then you just need to "activate" the virtualenv, and the cplex
package will automatically be accessible. For example, the following might work for you:
cd /home/yash/anaconda3/envs/my_env/
source bin/activate
# use pyomo and cplex here
# when you're done, deactivate the virtualenv, like so:
deactivate
Upvotes: 1
Reputation: 311
Installing CPLEX with conda only install the python library and engine runtime for that python library. This does not install what is not necessary for the library to run.
If you are looking for the cplex executable, you want to install CPLEX Community Edition then run [installDir]/python/setup.py mentionned above by Xavier.
I think you can signup and download CPLEX CE here: https://www.ibm.com/account/reg/us-en/signup?formid=urx-20028
Upvotes: 1
Reputation: 5095
Did you run
[installDir]/python/setup.py
from your Python environment?
Upvotes: 0