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".
This commit is contained in:
Miku AuahDark 2023-07-10 17:52:42 +08:00 committed by GitHub
parent 211e13b80a
commit a2848f40bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

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