mlflow: [BUG] can't run MLFlow project on Windows

System information

  • Have I written custom code (as opposed to using a stock example script provided in MLflow): no
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • MLflow installed from (source or binary): pip install mlflow in conda environmnet
  • MLflow version (run mlflow --version): 1.1.0
  • Python version: 3.7.3
  • npm version, if running the dev UI:
  • Exact command to reproduce: mlflow run <git-repository>

Describe the problem

When running the command mlflow run <git-repository> for a project that uses a conda environment, the project can’t be run because of a FileNotFoundError: [WinError 2] The system cannot find the file specified error.

Logs

2019/07/26 14:57:50 INFO mlflow.projects: === Running command 'source C:\Users\myUser\AppData\Local\Continuum\anaconda3\Scripts/../etc/profile.d/conda.sh && conda activate mlflow-5704e62345c83aec63a905fd394fede4b904cc8d 1>&2 && python run.py in run with ID '2115ac6375394aaea8a22376b81b1ee3' ===

Running the project fails because the command “source” is not available on Windows. The bug might have been introduced in #1576.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 18 (1 by maintainers)

Most upvoted comments

With mlflow 1.4.0, python 3.6 and conda 4.7.12, this issue can be fixed by changing this line in the source code. File mlflow\projects\__init__.py, line 687 return ["conda.bat activate %s" % (conda_env_name)] Windows CreateProcess could not find the file conda because it actually points to conda.bat in an Anaconda prompt.

I’ve experienced the same thing for mlflow ui

Hi all, hi @dbczumar .

still getting this in mlflow 2.1.1 (Python 3.9.15, Windows 11 Pro, mlflow Version: 2.1.1.).

Is this still a known issue? The solution suggested is not clear to me from the discussions above. Any ideas?

The command : mlflow run https://github.com/mlflow/mlflow-example.git -P alpha=5.0

gives the following error.

ERROR

Traceback (most recent call last):
  File "C:\Users\m\miniconda3\envs\env_explore\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\m\miniconda3\envs\env_explore\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\m\miniconda3\envs\env_explore\Scripts\mlflow.exe\__main__.py", line 7, in <module>
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\mlflow\cli.py", line 201, in run
    projects.run(
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\mlflow\projects\__init__.py", line 329, in run
    submitted_run_obj = _run(
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\mlflow\projects\__init__.py", line 102, in _run
    submitted_run = backend.run(
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\mlflow\projects\backend\local.py", line 77, in run
    work_dir = fetch_and_validate_project(project_uri, version, entry_point, params)
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\mlflow\projects\utils.py", line 137, in fetch_and_validate_project
    work_dir = _fetch_project(uri=uri, version=version)
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\mlflow\projects\utils.py", line 152, in _fetch_project
    use_temp_dst_dir = _is_zip_uri(parsed_uri) or not _is_local_uri(parsed_uri)     
  File "C:\Users\m\miniconda3\envs\env_explore\lib\site-packages\mlflow\projects\utils.py", line 109, in _is_local_uri
    resolved_uri = pathlib.Path(_parse_file_uri(uri)).resolve()
  File "C:\Users\m\miniconda3\envs\env_explore\lib\pathlib.py", line 1215, in resolve
    s = self._flavour.resolve(self, strict=strict)
  File "C:\Users\m\miniconda3\envs\env_explore\lib\pathlib.py", line 215, in resolve
    s = self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'https:\\github.com\\mlflow\\mlflow-example.git```

bump still getting this in mlflow 1.6

2020/02/26 21:51:31 INFO mlflow.projects: === Running command 'conda activate mlflow-394111e2a63ae021816efb57c1bd5a286db85045 && python train.py 0.5 0.1' in run with ID '73e7f6c5454a4e6aadc8ec6523b33afe' ===
Traceback (most recent call last):
  File "c:\tools\miniconda3\envs\py35mlflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\tools\miniconda3\envs\py35mlflow\Scripts\mlflow.exe\__main__.py", line 7, in <module>
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\mlflow\cli.py", line 134, in run
    run_id=run_id
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\mlflow\projects\__init__.py", line 288, in run
    use_conda=use_conda, storage_dir=storage_dir, synchronous=synchronous, run_id=run_id)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\mlflow\projects\__init__.py", line 171, in _run
    run_id=active_run.info.run_id)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\site-packages\mlflow\projects\__init__.py", line 510, in _run_entry_point
    process = subprocess.Popen(command, close_fds=True, cwd=work_dir, env=env)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "c:\tools\miniconda3\envs\py35mlflow\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

(py35mlflow) C:\dev\mkflow-example>mlflow run mlflow-example -P alpha=0.5 --no-conda
2020/02/26 21:52:07 INFO mlflow.projects: === Created directory C:\Users\benne\AppData\Local\Temp\tmpm0ugqa_p for downloading remote URIs passed to arguments of type 'path' ===
2020/02/26 21:52:07 INFO mlflow.projects: === Running command 'python train.py 0.5 0.1' in run with ID 'c8c9f66f88d34e8d87799c4718f1d9e7' ===
Traceback (most recent call last):
  File "train.py", line 11, in <module>
    from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
ModuleNotFoundError: No module named 'sklearn'
2020/02/26 21:52:07 ERROR mlflow.cli: === Run (ID 'c8c9f66f88d34e8d87799c4718f1d9e7') failed ===

mlflow models serve -m runs:/74b0dadee65644488c432981f75865dc/model --port 1234 --no-conda execution failed with

FileNotFoundError: [WinError 2] The system cannot find the file specified

In local windows machine this issue is fixed for –no-conda execution.

File name: mlflow\pyfunc\backend.py Class name:PyFuncBackend Function:serve

Original Line

subprocess.Popen([command.split(" ")], env=command_env).wait()

changed to

subprocess.Popen(command.split(" "), env=command_env).wait()

root cause: Issue is array of array command.split(" ") this will return array[] but passing subprocess.Popen([[]], env=command_env).wait(). When remove outer array started working for --no-conda following command working fine:

models serve -m runs:/74b0dadee65644488c432981f75865dc/model --port 1234 --no-conda

Steps to reproduce the issue:

On Windows: mlflow version:1.13.1 OS: Windows 10 Step 1) mlflow run . -P alpha=0.42 --no-conda executed successfully. Step 2): mlflow models serve -m runs:/74b0dadee65644488c432981f75865dc/model --port 1234 --no-conda execution failed.

ERROR: FileNotFoundError: [WinError 2] The system cannot find the file specified

Exception:

2021/02/18 12:34:08 INFO mlflow.models.cli: Selected backend for flavor ‘python_function’ 2021/02/18 12:34:08 INFO mlflow.pyfunc.backend: === Running command ‘waitress-serve --host=127.0.0.1 --port=1234 --ident=mlflow mlflow.pyfunc.scoring_server.wsgi:app’ Traceback (most recent call last): File “c:\users\userappdata\local\programs\python\python37\lib\runpy.py”, line 193, in _run_module_as_main “main”, mod_spec) File “c:\users\userappdata\local\programs\python\python37\lib\runpy.py”, line 85, in run_code exec(code, run_globals) File "C:\Users\userAppData\Local\Programs\Python\Python37\Scripts\mlflow.exe_main.py", line 7, in <module> File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\click\core.py”, line 829, in call return self.main(*args, **kwargs) File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\click\core.py”, line 782, in main rv = self.invoke(ctx) File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\click\core.py”, line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\click\core.py”, line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\click\core.py”, line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\click\core.py”, line 610, in invoke return callback(*args, **kwargs) File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\mlflow\models\cli.py”, line 57, in serve ).serve(model_uri=model_uri, port=port, host=host) File “c:\users\userappdata\local\programs\python\python37\lib\site-packages\mlflow\pyfunc\backend.py”, line 99, in serve subprocess.Popen([command.split(" ")], env=command_env).wait() File “c:\users\userappdata\local\programs\python\python37\lib\subprocess.py”, line 756, in init restore_signals, start_new_session) File “c:\users\userappdata\local\programs\python\python37\lib\subprocess.py”, line 1155, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified