Skip to content

Commit

Permalink
Prevent artifactual "running from outside your current environment" e…
Browse files Browse the repository at this point in the history
…rror (#15647)

Prevent warning when shutil.executable returns a symlink

Co-authored-by: Luca Antiga <luca@lightning.ai>
(cherry picked from commit 3248f33)
  • Loading branch information
lantiga authored and Borda committed Nov 16, 2022
1 parent 91d7a38 commit 2d2c902
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lightning_app/utilities/cli_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,11 @@ def _check_environment_and_redirect():
If not, this utility tries to redirect the ``lightning`` call to the environment executable (prompting the user to
install lightning for them there if needed).
"""
env_executable = shutil.which("python")
env_executable = os.path.realpath(shutil.which("python"))
sys_executable = os.path.realpath(sys.executable)

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

0 comments on commit 2d2c902

Please sign in to comment.