Skip to content

Commit 5f3d2cc

Browse files
ImLucasBrownLucas Brown
authored andcommitted
* improved search logic for UE python executable
1 parent e29a87a commit 5f3d2cc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

nxt_editor/integration/unreal/Content/Python/init_unreal.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import unreal
44
import subprocess
5+
from pathlib import Path
56
from functools import wraps
67

78

@@ -37,12 +38,23 @@ def is_nxt_available():
3738
return False
3839

3940
def get_python_exc_path():
41+
sys_exe = Path(sys.executable)
4042
exc_name = 'python'
43+
platform = 'Mac'
4144
if sys.platform == 'win32':
4245
exc_name = 'python.exe'
43-
46+
platform = 'Win64'
47+
# Check the python bundled with unreal first
48+
py_exe = sys_exe.parent.parent / f'ThirdParty/Python3/{platform}/{exc_name}'
49+
if py_exe.exists():
50+
return str(py_exe)
51+
# Fallback to guessing based on sys.prefix
4452
real_prefix = os.path.realpath(sys.prefix)
45-
return os.path.join(real_prefix, exc_name)
53+
py_exe = Path(real_prefix) / exc_name
54+
if py_exe.exists():
55+
return str(py_exe)
56+
raise FileNotFoundError(f'Cannot find python executable for pip install. '
57+
f'Checked {py_exe} and {real_prefix} / {exc_name}')
4658

4759
@fail_safe
4860
def install_nxt_to_interpreter():

0 commit comments

Comments
 (0)