Decision Optimization

 View Only
Expand all | Collapse all

Python API error: No module named 'cplex._internal._procedural'

  • 1.  Python API error: No module named 'cplex._internal._procedural'

    Posted Thu May 30, 2024 10:17 AM
    Edited by NICK PLOWDEN Fri May 31, 2024 09:47 AM

    Hi!

    Background:

    I have been using CPLEX through the python API smoothly on my PC (Ubuntu 22.04 LTS) and now I am trying to install CPLEX on my university's compute cluster for large scale computing (Red Hat Enterprise Linux 9.3). And this is where I encounter some resistance. I am hoping I simply overlooked some configuration and someone could kindly point it out to me here. Thanks!

    Problem:

    When calling model.solve (), an error was thrown:

    docplex.mp.utils.DOcplexException: Cannot solve model: no CPLEX runtime found.

    My code interacts with docplex API directly. But when I try to import cplex in python, I get the error mentioned in the title

    ModuleNotFoundError: No module named 'cplex._internal._procedural'

    The full trace is attached below (actual user path replaced by <user-path> for desensitization):

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/<user-path>/CPLEX_Studio2211/cplex/python/3.10/x86-64_linux/cplex/__init__.py", line 44, in <module>
        from .aborter import Aborter
      File "/<user-path>/CPLEX_Studio2211/cplex/python/3.10/x86-64_linux/cplex/aborter.py", line 13, in <module>
        from ._internal import _procedural as _proc
      File "/<user-path>/CPLEX_Studio2211/cplex/python/3.10/x86-64_linux/cplex/_internal/__init__.py", line 21, in <module>
        from . import _ostream
      File "/<user-path>/CPLEX_Studio2211/cplex/python/3.10/x86-64_linux/cplex/_internal/_ostream.py", line 17, in <module>
        from ._procedural import check_status
    ModuleNotFoundError: No module named 'cplex._internal._procedural'

    Some observations:

    • Due to my restricted user privilege on the cluster, I can't use the default install path provided by the CPLEX installer (btw I used the x86-64 linux installer, there is a linux system i/p version too but I am not sure what that is?) Regardless, it seems that the docplex API is able to locate the installed CPLEX, rather the installation is literally missing the definition for "_internal._procedural". As I am writing this, I quickly check the build/ directory of the cluster installation vs. my PC installation, and it confirms my observation. My PC build has a "_procedural.py" file under

      /opt/ibm/ILOG/CPLEX_Studio2211/cplex/python/3.10/x86-64_linux/build/lib/cplex/_internal/, , but the cluster installation doesn't have it. What could have caused this?

    • The installation on the cluster reports 6 non-fatal errors when it is completed. They are CRC errors, such as the one below.
      • Install File:             /<user-path>/CPLEX_Studio2211/opl/ant/bin/lcp.bat
                                  Status: ERROR
                                  Additional Notes: ERROR - Flexeraak8: invalid entry CRC (expected 0x2b4f5f15 but got 0xf061df8e)
    • I use a python environment when installing on cluster, while on PC I installed CPLEX on the base. Does this matter?

    Thanks in advance.

    Best regards,

    Yijie



    ------------------------------
    Yijie Tao
    ------------------------------



  • 2.  RE: Python API error: No module named 'cplex._internal._procedural'

    Posted Mon June 17, 2024 10:52 AM

    Hi Yijie,

    I also use a Python .venv for Cplex on RHEL 8.9 and did not encounter any issue in this case.
    My Cplex runtime, I installed by `pip install cplex`is located at
    ```
    <cplex-python-3.11/.venv>/bin/libcplex2211.so
    <cplex-python-3.11/.venv>/lib/python3.11/site-packages/cplex
    <cplex-python-3.11/.venv>/lib/python3.11/site-packages/cplex/_internal/libcplex2211.so
    <cplex-python-3.11/.venv>/lib/python3.11/site-packages/cplex/_internal/py311_cplex2211.so
    ...
    ```
    In your situation, I would try to check a `pip install cplex docplex` in a fresh venv makes a model.solves() work.
    Then run the setup.py that upgrade the cplex runtime toward your CPLEX_Studio2211 installation.

    Hope this helps



    ------------------------------
    Cédric Doens
    ------------------------------