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>
  • Loading branch information
lantiga and lantiga committed Nov 12, 2022
1 parent 19de273 commit 3248f33
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lightning_app/utilities/cli_helpers.py
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 3248f33

Please sign in to comment.