-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSTART.bat
More file actions
196 lines (165 loc) · 4.75 KB
/
Copy pathSTART.bat
File metadata and controls
196 lines (165 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@echo off
chcp 65001 >nul
cd /d "%~dp0"
set LOG=install.log
echo [%date% %time%] Start >> %LOG%
echo.
echo ========================================
echo Gemini Media Toolkit
echo ========================================
echo.
echo [1/4] Check Python...
:: ============================================
:: Find Python (跳过 Windows Store 假 Python)
:: ============================================
set PYTHON_CMD=
:: 1. 尝试 py 命令(推荐,会自动找真实 Python)
py --version >nul 2>&1
if not errorlevel 1 (
set PYTHON_CMD=py
goto :python_found
)
:: 2. 使用 where 查找所有 python,跳过 WindowsApps 的假货
for /f "tokens=*" %%i in ('where python 2^>nul') do (
echo %%i | findstr /i "WindowsApps" >nul
if errorlevel 1 (
set PYTHON_CMD=%%i
goto :python_found
)
)
:: 3. 检查常见安装路径
if exist "D:\python\python.exe" (
set PYTHON_CMD=D:\python\python.exe
goto :python_found
)
if exist "C:\Python312\python.exe" (
set PYTHON_CMD=C:\Python312\python.exe
goto :python_found
)
if exist "C:\Python311\python.exe" (
set PYTHON_CMD=C:\Python311\python.exe
goto :python_found
)
if exist "C:\Python310\python.exe" (
set PYTHON_CMD=C:\Python310\python.exe
goto :python_found
)
if exist "%LOCALAPPDATA%\Programs\Python\Python312\python.exe" (
set PYTHON_CMD=%LOCALAPPDATA%\Programs\Python\Python312\python.exe
goto :python_found
)
if exist "%LOCALAPPDATA%\Programs\Python\Python311\python.exe" (
set PYTHON_CMD=%LOCALAPPDATA%\Programs\Python\Python311\python.exe
goto :python_found
)
if exist "%LOCALAPPDATA%\Programs\Python\Python310\python.exe" (
set PYTHON_CMD=%LOCALAPPDATA%\Programs\Python\Python310\python.exe
goto :python_found
)
:: Python not found
echo [ERROR] Real Python not found!
echo.
echo Found Windows Store Python stub, but it cannot create venv.
echo.
echo Please install REAL Python 3.8+ from:
echo https://www.python.org/downloads/
echo.
echo IMPORTANT:
echo 1. Check "Add Python to PATH" during installation
echo 2. DO NOT use Windows Store Python
echo.
pause
start https://www.python.org/downloads/
exit /b 1
:python_found
echo [OK] Found Python: %PYTHON_CMD%
%PYTHON_CMD% --version
echo OK
echo [2/4] Create venv...
echo This may take 1-2 minutes...
:: Delete corrupted venv if exists
if exist "venv" (
echo Cleaning up old venv...
rmdir /s /q venv
)
:: Try to create venv with pip first
%PYTHON_CMD% -m venv venv >nul 2>&1
:: Check if venv was created
if not exist "venv\Scripts\python.exe" (
echo [WARN] Standard venv creation failed, trying without pip...
%PYTHON_CMD% -m venv venv --without-pip >nul 2>&1
if not exist "venv\Scripts\python.exe" (
echo [ERROR] Failed to create virtual environment!
echo.
echo Possible solutions:
echo 1. Run as Administrator
echo 2. Disable antivirus temporarily
echo 3. Reinstall Python with "pip" option checked
echo 4. Make sure you installed REAL Python, not Windows Store version
echo.
pause
exit /b 1
)
:: Install pip manually
echo Installing pip manually...
curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py
if exist "get-pip.py" (
venv\Scripts\python.exe get-pip.py >nul 2>&1
del get-pip.py
)
)
echo OK
echo [3/4] Activate venv...
call venv\Scripts\activate.bat
if errorlevel 1 (
echo [ERROR] Failed to activate virtual environment!
echo.
echo Deleting corrupted venv...
rmdir /s /q venv
echo Please run this script again.
echo.
pause
exit /b 1
)
echo OK
echo [4/4] Install packages...
echo This may take 2-3 minutes, please wait...
echo.
:: Upgrade pip first
python -m pip install --upgrade pip -q >nul 2>&1
:: Try with China mirror first
echo Installing with Aliyun mirror...
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple 2>&1
if errorlevel 1 (
echo.
echo [WARN] Aliyun mirror failed, trying Tsinghua mirror...
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple 2>&1
)
if errorlevel 1 (
echo.
echo [WARN] Tsinghua mirror failed, trying official PyPI...
pip install -r requirements.txt 2>&1
)
if errorlevel 1 (
echo.
echo [ERROR] Failed to install dependencies!
echo.
echo Please check:
echo 1. Internet connection is working
echo 2. Firewall is not blocking pip
echo 3. Disk space is sufficient
echo.
pause
exit /b 1
)
echo.
echo [OK] Dependencies installed successfully
echo.
echo ========================================
echo Done! Run start.vbs to launch
echo Or run START.bat again to restart
echo ========================================
echo.
timeout /t 3 >nul
start "" pythonw main.py
exit