mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-09 19:46:44 +02:00
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:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user