Fix FileNotFoundError for /usr/local/CyberPanel/bin/python on fresh install

- install.py: only use system Python or /usr/local/CyberCP/bin/python for migrations;
  never add /usr/local/CyberPanel paths to candidate list (often missing on fresh install)
- install_utils.py: if command uses /usr/local/CyberPanel/bin/python and it does not
  exist, substitute /usr/bin/python3 and force shell=True so old/cached install.py
  also works without failing
This commit is contained in:
master3395
2026-02-04 22:26:42 +01:00
parent d32a50c774
commit 527938cd21
2 changed files with 13 additions and 7 deletions

View File

@@ -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:

View File

@@ -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