From a2848f40bb587515d2f18a6140d9ca4bb7035f38 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Mon, 10 Jul 2023 17:52:42 +0800 Subject: [PATCH] Use sys.executable to determine --pycmd (#715) * Use sys.executable to determine --pycmd In some systems, `python` may not correctly refer to the virtual environment's `python` used for webui, or it even refers to Python 2. Also in Windows, when the webui is run directly through `venv\Scripts\python` without activating the virtual environment, the system python will be picked instead of the one inside virtual environment. * Remove reduntant "or". --- config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 959b2b7..f237d51 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,5 @@ import argparse +import sys import torch from multiprocessing import cpu_count @@ -33,10 +34,11 @@ class Config: @staticmethod def arg_parse() -> tuple: + exe = sys.executable or "python" parser = argparse.ArgumentParser() parser.add_argument("--port", type=int, default=7865, help="Listen port") parser.add_argument( - "--pycmd", type=str, default="python", help="Python command" + "--pycmd", type=str, default=exe, help="Python command" ) parser.add_argument("--colab", action="store_true", help="Launch in colab") parser.add_argument(