diff --git a/install/install.py b/install/install.py index bfbeb45cd..c087e2f8a 100644 --- a/install/install.py +++ b/install/install.py @@ -3367,19 +3367,16 @@ password="%s" if not self.ensureVirtualEnvironmentSetup(): logging.InstallLog.writeToFile("WARNING: No venv found; will try system Python", 1) - # Find Python: try system Python first so we never use missing /usr/local/CyberPanel/bin/python - # (venv may not exist yet; /usr/local/CyberPanel is legacy and often missing on fresh install) + # Find Python: use only system Python or CyberCP venv (never /usr/local/CyberPanel - often missing on fresh install) python_paths = [ "/usr/bin/python3", "/usr/local/bin/python3", ] if sys.executable and sys.executable not in python_paths: python_paths.append(sys.executable) - python_paths.extend([ - "/usr/local/CyberCP/bin/python", - "/usr/local/CyberPanel/bin/python", - "/usr/local/CyberPanel-venv/bin/python", - ]) + # Only add venv if it exists (avoid FileNotFoundError) + if os.path.isfile("/usr/local/CyberCP/bin/python"): + python_paths.append("/usr/local/CyberCP/bin/python") python_path = None for path in python_paths: diff --git a/install/install_utils.py b/install/install_utils.py index 5549550fc..7a5f65974 100644 --- a/install/install_utils.py +++ b/install/install_utils.py @@ -573,6 +573,15 @@ def call(command, distro, bracket, message, log=0, do_exit=0, code=os.EX_OK, she command = re.sub(r'^(\s*)(?:sudo\s+)?(mysql|mariadb)(\s)', r'\g<1>' + mysql_bin + r'\g<3>', command, count=1) shell = True + # CRITICAL: /usr/local/CyberPanel/bin/python often missing on fresh install; use system Python for manage.py + if '/usr/local/CyberPanel/bin/python' in command and not os.path.isfile('/usr/local/CyberPanel/bin/python'): + fallback = '/usr/bin/python3' + if not os.path.isfile(fallback): + fallback = '/usr/local/bin/python3' + if os.path.isfile(fallback): + command = command.replace('/usr/local/CyberPanel/bin/python', fallback, 1) + shell = True # ensure shell so path with spaces is not split + finalMessage = 'Running: %s' % (message) stdOut(finalMessage, log) count = 0