IBMDecisionOptimization / Decision-Optimization-with-CPLEX-samples

20 stars 9 forks source link

Error when installing the Cplex #7

Closed latkm closed 3 years ago

latkm commented 3 years ago

Hello,

I was installing Cplex to try the free version. Everything seemed to run smoothly. Yet, setting up the Python API for of Cplex, I got to the point where I was instructed the following (as per the installation screen)

Installing the engines in your Python environment
-------------------------------------------------

If you want to use the CPLEX or CP Optimizer engines through their Python 
APIs, you need to tell Python where to find them.  To do so, enter the 
following command into a terminal :
<<<<<<
python /opt/ibm/ILOG/CPLEX_Studio_Community201/python/setup.py install
>>>>>>

when executing the command above, I got the following error:

(km) l@l-ThinkPad-X1-Yoga-3rd:/opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/python/3.8/x86-64_linux$ python /opt/ibm/ILOG/CPLEX_Studio_Community201/python/setup.py install
['/opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/python/3.7/x86-64_linux/cplex']
['/opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/python/3.7/x86-64_linux/setup.py']
Invoking ['/home/l/anaconda3/envs/km/bin/python', 'setup.py', 'install'] in /opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/python/3.7/x86-64_linux
/home/l/anaconda3/envs/km/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'zip_safe'
  warnings.warn(msg)
running install
running build
running build_py
creating build
error: could not create 'build': Permission denied
Installation of CPLEX failed, code = 1

This is Ubuntu 20.04. Any help will be much appreaciated.

vlkong commented 3 years ago

Hi,

If you want to test the community edition, the easy way is just:

$ pip install cplex

(installs the CPLEX optimization engines) then

$ pip install docplex

(installs the DOCplex modeling package.

If you want to install from your local community edition installer, here's some details:

The setup.py script uses Pythons's distutils to create a distrib of everything that needs to be installed, then install the software in your python. The error you have is that it is trying to write to a directory that he cannot write to (here, it looks like that you cannot write to /opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/python/3.7/x86-64_linux/).

As you seem to be installing in your own anaconda env, I recommand copying the content of /opt/ibm/ILOG/CPLEX_Studio_Community201/python to your home dir:

$ cp -r /opt/ibm/ILOG/CPLEX_Studio_Community201/cplex/python/3.7/x86-64_linux ~/CPLEX_python
$ cd ~/CPLEX_python
$ python setup.py install
vlkong commented 3 years ago

Closing issue that has no changes for 3 months