Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

PyThon + CPLEX Installation + Conflict

  • 1.  PyThon + CPLEX Installation + Conflict

    Posted Wed February 20, 2019 03:24 PM

    Originally posted by: BahmanBornay


    Hello Everyone,

     

    I am new to Python and as I run the following code in Anaconda terminal: conda install -c ibmdecisionoptimization cplex 

    it takes a while "searching for environment" and then this error pops up: 

     

    (base) C:\Users\bahma>conda install -c ibmdecisionoptimization cplex
    Solving environment: failed

    UnsatisfiableError: The following specifications were found to be in conflict:
      - anaconda==2018.12=py37_0
      - cplex
    Use "conda info <package>" to see the dependencies for each package.

     

    This also happens when I use the pip install cplex code using window terminal (CMD). 

    I have already installed docplex using pip. 

    Python installation path on my laptop: C:\Users\bahma\AppData\Local\Programs\Python\Python37

    conda Installation Path on my laptop: C:\Users\bahma\AppData\Local\conda\conda

    setup.py in the directory of the installation of CPLEX Studio IDE: C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\python\3.6\x64_win64

    (I see three folders: Python 2.7, Python 3.5, and Python 3.6, in this directory (CPlex installation directory) and my current Python version is 3.7.2

    and a Picture of m y environment variable path, where I had added the above-mentioned directories is attached.

    I am on a 64-bit windows and I use IntelliJ IDE for coding my model, and after running the code, an error is popping up saying I need to install CPLEX.

    I would appreciate if anyone could help me resolve this issue.

     

    Regards,
    Bahman


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: PyThon + CPLEX Installation + Conflict

    Posted Wed February 20, 2019 03:41 PM

    This is expected because, as stated in the detailed system requirements, CPLEX 12.8 does not support Python 3.7. You will have to use Python 2.7, 3.5, or 3.6. In this thread you can see that Python 3.7 support is coming soon, though.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: PyThon + CPLEX Installation + Conflict

    Posted Wed February 20, 2019 03:49 PM

    Originally posted by: BahmanBornay


    Hey RyanKersh,

     

    I appreciate your prompt reply. So, I will have to install an older version of Python, i.e. Python 3.6.

     

    Regards,
    Bahman 


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: PyThon + CPLEX Installation + Conflict

    Posted Wed February 20, 2019 11:54 PM

    Originally posted by: BahmanBornay


    Hey RyanKersh,

     

    I kept Python 3.7.2 version in my windows, then I installed Pyhton 3.6. However, in the terminal (both Anaconda and windows terminal) when I type: python, the following script pops up:

     

    Windows Terminal:

    C:\Users\bahma>py -3
    Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

    Windows Terminal:

    :\Users\bahma>python
    Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

     

    Anaconda terminal:

    (base) C:\Users\bahma>python
    Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

    Anaconda terminal:

    (base) C:\Users\bahma>py -3
    Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

     

    When I want to install the cplex using windows terminal:

    C:\Users\bahma>cd C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\python\3.6\x64_win64

    C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\python\3.6\x64_win64>python setup.py install
    Traceback (most recent call last):
      File "setup.py", line 70, in <module>
        main()
      File "setup.py", line 53, in main
        raise Exception(VERSION_ERROR)
    Exception: CPLEX 12.8.0.0 is not compatible with this version of Python.

    C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\python\3.6\x64_win64>
     

    I would appreciate if you share your workaround if any.

     

    Regards,
    Bahman 


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: PyThon + CPLEX Installation + Conflict

    Posted Thu February 21, 2019 01:27 AM

    As you can see from your console output, your default Python is still 3.7 and that is what is used when you just type

    python setup.py install

    You have (at least) these options:

    1. Remove Python 3.7 completely
    2. Make sure that Python 3.6 is your default Python (you can probably find information for doing that on some Python forum)
    3. Explicitly invoke Python 3.6 when calling setup.py by not only saying "python" but by instead specifying the full absolute path to the Python 3.6 binary.

    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: PyThon + CPLEX Installation + Conflict

    Posted Thu February 21, 2019 01:28 PM

    Originally posted by: BahmanBornay


    Hey Daniel,

     

    As you recommended, I uninstalled Python 3.7, and installed Python 3.6

    I got the following error:

    C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\python\3.6\x64_win64>python setup.py install
    running install
    running build
    running build_py
    creating build
    error: could not create 'build': Access is denied

    C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\python\3.6\x64_win64>

     

    by right clicking on cmd and running it again as administrator, the problem was solved.

     

    Regards,
    Bahman


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: PyThon + CPLEX Installation + Conflict

    Posted Fri February 22, 2019 07:56 AM

    This is just a wild guess: are you trying to install into a location that requires administrator privileges? Do things work any better if you execute with administrator privileges?


    #CPLEXOptimizers
    #DecisionOptimization