# Quick fix script for portable Python environment # This will update the run scripts to properly set Python path $envFolder = "portable_python" $projectRoot = $PWD.Path Write-Host "[+] Updating run scripts to fix module import issues..." -ForegroundColor Cyan # Create script to run the project $runScriptContent = @" # Run Pharmacy Sales Prediction System # Activate environment . "`$PSScriptRoot\activate.ps1" # Change to project directory Set-Location "$projectRoot" # Run main program with path configuration python.exe -c "import sys; sys.path.insert(0, ''); import run_pharmacy_prediction" "@ $runScriptPath = Join-Path -Path $envFolder -ChildPath "run_project.ps1" $runScriptContent | Set-Content $runScriptPath -Encoding UTF8 # Create script to run API service $apiScriptContent = @" # Run Pharmacy Sales Prediction API Service # Activate environment . "`$PSScriptRoot\activate.ps1" # Change to project directory Set-Location "$projectRoot" # Run API service with path configuration python.exe -c "import sys; sys.path.insert(0, ''); import api" "@ $apiScriptPath = Join-Path -Path $envFolder -ChildPath "run_api.ps1" $apiScriptContent | Set-Content $apiScriptPath -Encoding UTF8 # Create a generic Python script launcher $pythonRunnerContent = @" # Generic Python Script Runner # Activate environment . "`$PSScriptRoot\activate.ps1" # Change to project directory Set-Location "$projectRoot" # Check if script parameter was provided if (`$args.Count -eq 0) { Write-Host "[!] Error: No Python script specified" -ForegroundColor Red Write-Host "Usage: .\run_script.ps1 " -ForegroundColor Yellow exit 1 } # Get script name from arguments `$scriptName = `$args[0] # Run Python script with path configuration python.exe -c "import sys; sys.path.insert(0, ''); exec(open('`$scriptName').read())" "@ $scriptRunnerPath = Join-Path -Path $envFolder -ChildPath "run_script.ps1" $pythonRunnerContent | Set-Content $scriptRunnerPath -Encoding UTF8 Write-Host "`n[+] Scripts updated successfully!" -ForegroundColor Green Write-Host "`nUsage Instructions:" -ForegroundColor Yellow Write-Host "1. Run project: ./$envFolder/run_project.ps1" -ForegroundColor White Write-Host "2. Run API service: ./$envFolder/run_api.ps1" -ForegroundColor White Write-Host "3. Run any script: ./$envFolder/run_script.ps1 " -ForegroundColor White