Betty Betty - 3 years ago 282
Linux Question

ImportError: No module named 'cplex' Python on Linux

I am trying to run python scripts on a HPC machine (RedHatEntrepriseServer). CPLEX module is already installed by adminastrators but I still have this error in importing cplex module in python.

ImportError: No module named 'cplex'

I know it is common error and I found that I may need to update PYTHONPATH variable with cplex home directory, but I can't find this home directory. Does anyone have an idea or suggestion to solve this problem?!

Many thanks!

Answer Source

Thanks to skr and danche comments, here is how I solved the problem:

I looked for cplex location by using this command:

find / -iname "cplex"

Then I updated the PYTHONPATH variable with this location:

export PYTHONPATH=$PYTHONPATH:/local/software/cplex/12.6.1/cplex/python/2.6/x86-64_linux

I updated my .bashrc file with last command so each time I log in it is set automatically.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download