fix: update verify_vision.py for Python 3.13 compatibility

- Use latest PyTorch versions (old ones don't exist for Python 3.13)
- Install PaddleOCR without PyMuPDF (avoids build errors)
- Skip PyMuPDF which requires Visual Studio build tools
This commit is contained in:
LemonNexus 2026-02-11 11:54:01 +00:00
parent b9ff965185
commit 049a59136d
2 changed files with 76 additions and 21 deletions

30
fix_pytorch_python313.bat Normal file
View File

@ -0,0 +1,30 @@
@echo off
REM Fix PyTorch for Python 3.13 (LATEST VERSIONS)
echo ==========================================
echo Fixing PyTorch for Python 3.13
echo ==========================================
echo.
echo [1/3] Uninstalling broken packages...
pip uninstall -y torch torchvision torchaudio paddlepaddle-gpu paddlepaddle paddleocr 2>nul
echo [2/3] Installing LATEST PyTorch (Python 3.13 compatible)...
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
echo [3/3] Installing LATEST PaddlePaddle...
pip install paddlepaddle
pip install paddleocr
echo.
echo ==========================================
echo Testing installation...
echo ==========================================
python -c "import torch; print(f'PyTorch: {torch.__version__}')"
python -c "import paddle; print(f'PaddlePaddle: {paddle.__version__}')"
python -c "from paddleocr import PaddleOCR; print('PaddleOCR: OK')"
echo.
echo ==========================================
echo Done! Restart the app.
echo ==========================================
@pause

View File

@ -1,5 +1,5 @@
"""
Verify and fix Computer Vision dependencies
Verify and fix Computer Vision dependencies for Python 3.13
"""
import subprocess
import sys
@ -46,23 +46,43 @@ def check_opencv():
return False
def install_fix():
"""Install working versions."""
print("\n🔧 Installing fixed versions...")
"""Install working versions for Python 3.13."""
print("\n🔧 Installing packages for Python 3.13...")
packages = [
"torch==2.1.2",
"torchvision==0.16.2",
# Install latest PyTorch (Python 3.13 compatible)
print("\n[1/3] Installing PyTorch (latest)...")
subprocess.check_call([
sys.executable, "-m", "pip", "install",
"torch", "torchvision",
"--index-url", "https://download.pytorch.org/whl/cpu"
])
# Install PaddlePaddle (latest for Python 3.13)
print("\n[2/3] Installing PaddlePaddle...")
subprocess.check_call([
sys.executable, "-m", "pip", "install",
"paddlepaddle"
])
# Install PaddleOCR WITHOUT PyMuPDF (it fails to build)
print("\n[3/3] Installing PaddleOCR (without PyMuPDF)...")
subprocess.check_call([
sys.executable, "-m", "pip", "install",
"paddleocr", "--no-deps" # Install without dependencies first
])
# Then install PaddleOCR dependencies except PyMuPDF
print("\n[4/4] Installing PaddleOCR dependencies...")
deps = [
"shapely", "scikit-image", "imgaug", "pyclipper",
"lxml", "tqdm", "numpy", "visualdl", "rapidfuzz",
"opencv-python", "opencv-contrib-python",
"cython", "Pillow", "pyyaml", "pdf2docx",
"premailer", "attrdict", "openpyxl", "fire", "fonttools"
]
print("Installing PyTorch CPU version...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall"] + packages)
print("Installing PaddlePaddle...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "paddlepaddle==2.5.2"])
print("Installing PaddleOCR...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", "paddleocr==2.7.0.3"])
subprocess.check_call([
sys.executable, "-m", "pip", "install"
] + deps)
print("\n✅ Installation complete!")
@ -87,13 +107,18 @@ if __name__ == "__main__":
print("❌ Some dependencies missing or broken.")
response = input("\nWould you like to auto-fix? (y/n): ")
if response.lower() == 'y':
try:
install_fix()
print("\nPlease restart the app.")
print("\n✅ Installation complete! Please restart the app.")
except Exception as e:
print(f"\n❌ Installation failed: {e}")
print("\nTry manual installation:")
print("1. pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu")
print("2. pip install paddlepaddle")
print("3. pip install paddleocr --no-deps")
print("4. pip install shapely scikit-image opencv-python")
else:
print("\nManual fix instructions:")
print("1. pip uninstall torch torchvision paddlepaddle paddleocr")
print("2. pip install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cpu")
print("3. pip install paddlepaddle==2.5.2 paddleocr==2.7.0.3")
print("\nSkipping installation.")
print()
input("Press Enter to exit...")