Skip to content

Commit 3248f33

Browse files
authored
Prevent artifactual "running from outside your current environment" error (#15647)
Prevent warning when shutil.executable returns a symlink Co-authored-by: Luca Antiga <[email protected]>
1 parent 19de273 commit 3248f33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lightning_app/utilities/cli_helpers.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,11 @@ def _check_environment_and_redirect():
299299
If not, this utility tries to redirect the ``lightning`` call to the environment executable (prompting the user to
300300
install lightning for them there if needed).
301301
"""
302-
env_executable = shutil.which("python")
302+
env_executable = os.path.realpath(shutil.which("python"))
303+
sys_executable = os.path.realpath(sys.executable)
303304

304305
# on windows, the extension might be different, where one uses `.EXE` and the other `.exe`
305-
if env_executable.lower() != sys.executable.lower():
306+
if env_executable.lower() != sys_executable.lower():
306307
logger.info(
307308
"Lightning is running from outside your current environment. Switching to your current environment."
308309
)

0 commit comments

Comments
 (0)