Repository: PrefectHQ/prefect

Issue:
Windows prefect deploy does not work with docker
### First check

- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the Prefect documentation for this issue.
- [X] I checked that this issue is related to Prefect and not one of its dependencies.

### Bug summary

prefect deploy -n "name of deployment" does not work anymore on Windows. 

### Reproduction

```python3
prefect deploy -n
```


### Error

```python3
Running deployment build steps...
 > Running run_shell_script step...
 > Running build_docker_image step...
Unable to load step function: prefect_docker.deployments.steps.build_docker_image. Attempting install of prefect-docker>=0.3.11.
Traceback (most recent call last):
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\deployments\steps\core.py", line 149, in run_steps
    step_output = await run_step(step, upstream_outputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\deployments\steps\core.py", line 119, in run_step
    step_func = _get_function_for_step(fqn, requires=keywords.get("requires"))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\deployments\steps\core.py", line 83, in _get_function_for_step
    subprocess.check_call(
  File "C:\Users\JKANG1\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 408, in check_call
    retcode = call(*popenargs, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 389, in call
    with Popen(*popenargs, **kwargs) as p:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\JKANG1\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\cli\_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\utilities\asyncutils.py", line 255, in coroutine_wrapper
    return call()
           ^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 382, in __call__
    return self.result()
           ^^^^^^^^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 282, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 168, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 345, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\cli\deploy.py", line 292, in deploy
    await _run_single_deploy(
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\client\utilities.py", line 51, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\cli\deploy.py", line 595, in _run_single_deploy
    await run_steps(build_steps, step_outputs, print_function=app.console.print)
  File "C:\Users\JKANG1\PycharmProjects\site_analytics\.venv\Lib\site-packages\prefect\deployments\steps\core.py", line 177, in run_steps
    raise StepExecutionError(f"Encountered error while running {fqn}") from exc
prefect.deployments.steps.core.StepExecutionError: Encountered error while running prefect_docker.deployments.steps.build_docker_image
An exception occurred.
```


### Versions

```Text
Version:             2.14.4
API version:         0.8.4
Python version:      3.11.6
Git commit:          d2cf30f4
Built:               Thu, Nov 9, 2023 4:48 PM
OS/Arch:             win32/AMD64
Profile:             default
Server type:         cloud
```


### Additional context

_No response_


Discussion:
Thanks for the report! It looks like this is an issue with how we're calling the python executable on Windows. What version of windows are you using?
Hi @urimandujano Thanks for the note. This seems odd as I think I remember in an earlier version (maybe around 2.13 something) it did not have this issue. 

Windows version below:
![image](https://github.com/PrefectHQ/prefect/assets/72617548/0e1e98aa-c255-46e9-afa1-072b048b2097)

Thanks! It's interesting that this was working earlier because we did some [recent work to fix an issue like this](https://github.com/PrefectHQ/prefect/pull/10547). We'll look into this. 
@urimandujano 
I can confirm the issue. I had to downgrade the Prefect version to 
Version:             2.11.0
API version:         0.8.4
Python version:      3.10.11
Git commit:          eeb9e219

This works for now

Resolving patch:
diff --git a/src/prefect/deployments/steps/core.py b/src/prefect/deployments/steps/core.py
--- a/src/prefect/deployments/steps/core.py
+++ b/src/prefect/deployments/steps/core.py
@@ -13,6 +13,7 @@
 import os
 import re
 import subprocess
+import sys
 import warnings
 from copy import deepcopy
 from importlib import import_module
@@ -23,7 +24,6 @@
 from prefect.logging.loggers import get_logger
 from prefect.settings import PREFECT_DEBUG_MODE
 from prefect.utilities.importtools import import_object
-from prefect.utilities.processutils import get_sys_executable
 from prefect.utilities.templating import (
     apply_values,
     resolve_block_document_references,
@@ -83,9 +83,7 @@ def _get_function_for_step(
             raise
 
     try:
-        subprocess.check_call(
-            [get_sys_executable(), "-m", "pip", "install", *packages],
-        )
+        subprocess.check_call([sys.executable, "-m", "pip", "install", *packages])
     except subprocess.CalledProcessError:
         get_logger("deployments.steps.core").warning(
             "Unable to install required packages for %s", fully_qualified_name


Test patch: