From 049a59136d775530a722d99f8a1d3b94acbc94be Mon Sep 17 00:00:00 2001 From: LemonNexus Date: Wed, 11 Feb 2026 11:54:01 +0000 Subject: [PATCH] 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 --- fix_pytorch_python313.bat | 30 ++++++++++++++++++ verify_vision.py | 67 +++++++++++++++++++++++++++------------ 2 files changed, 76 insertions(+), 21 deletions(-) create mode 100644 fix_pytorch_python313.bat diff --git a/fix_pytorch_python313.bat b/fix_pytorch_python313.bat new file mode 100644 index 0000000..6591293 --- /dev/null +++ b/fix_pytorch_python313.bat @@ -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 \ No newline at end of file diff --git a/verify_vision.py b/verify_vision.py index 8560272..a9ffd09 100644 --- a/verify_vision.py +++ b/verify_vision.py @@ -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': - install_fix() - print("\nPlease restart the app.") + try: + install_fix() + 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...") \ No newline at end of file