ragflow_preprocess/install_windows.ps1
2025-03-27 17:59:10 +01:00

107 lines
4.5 KiB
PowerShell

# PowerShell installation script for Ragflow PDF Preprocessing
Write-Host "======================================================" -ForegroundColor Cyan
Write-Host " Ragflow PDF Preprocessing Installation" -ForegroundColor Cyan
Write-Host "======================================================" -ForegroundColor Cyan
Write-Host ""
# Check if PowerShell is running as administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-not $isAdmin) {
Write-Host "Note: For installing system dependencies, it is recommended to run this script as administrator." -ForegroundColor Yellow
Write-Host "You can continue without administrator privileges, but some features might not be installed correctly." -ForegroundColor Yellow
$continue = Read-Host "Do you want to continue? (Y/N)"
if ($continue -ne "Y" -and $continue -ne "y") {
Write-Host "Installation cancelled." -ForegroundColor Red
exit
}
}
# Check if Python is installed
try {
$pythonVersion = python --version
Write-Host "Python detected: $pythonVersion" -ForegroundColor Green
} catch {
Write-Host "Error: Python is not installed or not in PATH." -ForegroundColor Red
Write-Host "Please install Python 3.8 or higher from https://www.python.org/downloads/" -ForegroundColor Red
Write-Host "Make sure to check 'Add Python to PATH' during installation." -ForegroundColor Red
Read-Host "Press ENTER to exit"
exit
}
# Create virtual environment
Write-Host "Creating virtual environment..." -ForegroundColor Cyan
python -m venv venv
if (-not $?) {
Write-Host "Error creating virtual environment." -ForegroundColor Red
Read-Host "Press ENTER to exit"
exit
}
# Activate virtual environment
Write-Host "Activating virtual environment..." -ForegroundColor Cyan
& .\venv\Scripts\Activate.ps1
# Update pip
Write-Host "Updating pip..." -ForegroundColor Cyan
python -m pip install --upgrade pip
# Install dependencies
Write-Host "Installing dependencies..." -ForegroundColor Cyan
pip install -e .
if (-not $?) {
Write-Host "Error installing dependencies." -ForegroundColor Red
Read-Host "Press ENTER to exit"
exit
}
# Check if Tesseract is installed
$tesseractPaths = @(
"C:\Program Files\Tesseract-OCR\tesseract.exe",
"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe",
"C:\Tesseract-OCR\tesseract.exe"
)
$tesseractInstalled = $false
foreach ($path in $tesseractPaths) {
if (Test-Path $path) {
$tesseractInstalled = $true
Write-Host "Tesseract OCR detected at: $path" -ForegroundColor Green
break
}
}
if (-not $tesseractInstalled) {
Write-Host "Tesseract OCR was not detected." -ForegroundColor Yellow
Write-Host "The application requires Tesseract OCR for text recognition." -ForegroundColor Yellow
Write-Host "Please install it from: https://github.com/UB-Mannheim/tesseract/wiki" -ForegroundColor Yellow
}
# Check if Ollama server is accessible
try {
$response = Invoke-WebRequest -Uri "http://217.182.105.173:11434/api/version" -UseBasicParsing -ErrorAction SilentlyContinue
if ($response.StatusCode -eq 200) {
Write-Host "Ollama server is accessible at 217.182.105.173:11434." -ForegroundColor Green
}
} catch {
Write-Host "Warning: Cannot connect to Ollama server at 217.182.105.173:11434." -ForegroundColor Yellow
Write-Host "Make sure you have network connectivity to the Ollama server." -ForegroundColor Yellow
Write-Host "This is required for the LLM features of the application." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "======================================================" -ForegroundColor Cyan
Write-Host "Installation completed successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Cyan
Write-Host "1. Make sure Tesseract OCR is installed" -ForegroundColor White
Write-Host " (https://github.com/UB-Mannheim/tesseract/wiki)" -ForegroundColor White
Write-Host "2. Make sure you have network connectivity to the Ollama server at 217.182.105.173:11434" -ForegroundColor White
Write-Host "3. To launch the application, run:" -ForegroundColor White
Write-Host "" -ForegroundColor White
Write-Host " .\launch_windows.ps1" -ForegroundColor White
Write-Host "" -ForegroundColor White
Write-Host "Or use the launch_windows.bat script" -ForegroundColor White
Write-Host "======================================================" -ForegroundColor Cyan
Write-Host ""
Read-Host "Press ENTER to exit"