Skip to content

Commit a2848f4

Browse files
authored
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".
1 parent 211e13b commit a2848f4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import sys
23
import torch
34
from multiprocessing import cpu_count
45

@@ -33,10 +34,11 @@ def __init__(self):
3334

3435
@staticmethod
3536
def arg_parse() -> tuple:
37+
exe = sys.executable or "python"
3638
parser = argparse.ArgumentParser()
3739
parser.add_argument("--port", type=int, default=7865, help="Listen port")
3840
parser.add_argument(
39-
"--pycmd", type=str, default="python", help="Python command"
41+
"--pycmd", type=str, default=exe, help="Python command"
4042
)
4143
parser.add_argument("--colab", action="store_true", help="Launch in colab")
4244
parser.add_argument(

0 commit comments

Comments
 (0)