Skip to content

Conda-Based Environments Are Not Detected on Windows and Python 3.15 #649

Description

@popescu-v

Description

Conda-based environments are not detected on Windows when khiops 11.0.2.0 is used with Python 3.15.

The environment detection code in KhiopsLocalRunner falls back on detecting system-wide Pip installation and fails for a different reason:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import sys; import khiops.core as kh; return_code = kh.get_runner().print_status(); sys.exit(return_code)
                                                        ~~~~~~~~~~~~~^^
  File "C:\Users\runneradmin\miniconda3\envs\test\lib\python\site-packages\khiops\core\internals\runner.py", line 1644, in get_runner
    _khiops_runner = KhiopsLocalRunner()
  File "C:\Users\runneradmin\miniconda3\envs\test\lib\python\site-packages\khiops\core\internals\runner.py", line 1016, in __init__
    self._initialize_khiops_environment()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\runneradmin\miniconda3\envs\test\lib\python\site-packages\khiops\core\internals\runner.py", line 1020, in _initialize_khiops_environment
    installation_method = _infer_khiops_installation_method(
        environment=runner_environment
    )
  File "C:\Users\runneradmin\miniconda3\envs\test\lib\python\site-packages\khiops\core\internals\runner.py", line 320, in _infer_khiops_installation_method
    if importlib.util.find_spec("khiops") is not None:
       ^^^^^^^^^^^^^^
AttributeError: module 'importlib' has no attribute 'util'
Error: Process completed with exit code 1.

The immediate "fix" is to add the proper import:

import importlib.util
...
if importlib.util.find_spec("khiops") is not None:
    ...

But this, while necessary, would merely result in silently misdetecting the installation method as system-wide Pip, whence masking the real bug.

One hypothesis is that _infer_env_bin_dir_for_conda_based_installation misbehaves on Windows and Python 3.15.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority/0-HighSize/Hours

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions