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:
parent
b9ff965185
commit
049a59136d
|
|
@ -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
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Verify and fix Computer Vision dependencies
|
Verify and fix Computer Vision dependencies for Python 3.13
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -46,23 +46,43 @@ def check_opencv():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def install_fix():
|
def install_fix():
|
||||||
"""Install working versions."""
|
"""Install working versions for Python 3.13."""
|
||||||
print("\n🔧 Installing fixed versions...")
|
print("\n🔧 Installing packages for Python 3.13...")
|
||||||
|
|
||||||
packages = [
|
# Install latest PyTorch (Python 3.13 compatible)
|
||||||
"torch==2.1.2",
|
print("\n[1/3] Installing PyTorch (latest)...")
|
||||||
"torchvision==0.16.2",
|
subprocess.check_call([
|
||||||
|
sys.executable, "-m", "pip", "install",
|
||||||
|
"torch", "torchvision",
|
||||||
"--index-url", "https://download.pytorch.org/whl/cpu"
|
"--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"
|
||||||
]
|
]
|
||||||
|
subprocess.check_call([
|
||||||
print("Installing PyTorch CPU version...")
|
sys.executable, "-m", "pip", "install"
|
||||||
subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall"] + packages)
|
] + deps)
|
||||||
|
|
||||||
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"])
|
|
||||||
|
|
||||||
print("\n✅ Installation complete!")
|
print("\n✅ Installation complete!")
|
||||||
|
|
||||||
|
|
@ -87,13 +107,18 @@ if __name__ == "__main__":
|
||||||
print("❌ Some dependencies missing or broken.")
|
print("❌ Some dependencies missing or broken.")
|
||||||
response = input("\nWould you like to auto-fix? (y/n): ")
|
response = input("\nWould you like to auto-fix? (y/n): ")
|
||||||
if response.lower() == 'y':
|
if response.lower() == 'y':
|
||||||
|
try:
|
||||||
install_fix()
|
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:
|
else:
|
||||||
print("\nManual fix instructions:")
|
print("\nSkipping installation.")
|
||||||
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()
|
print()
|
||||||
input("Press Enter to exit...")
|
input("Press Enter to exit...")
|
||||||
Loading…
Reference in New Issue