#!/usr/bin/env python3 """ Install script for AccountForger dependencies. Handles PyQt5 installation across different platforms. """ import sys import subprocess import platform def install_package(package): """Install a package using pip""" try: subprocess.check_call([sys.executable, "-m", "pip", "install", package]) return True except subprocess.CalledProcessError: return False def install_pyqt5(): """Install PyQt5 with platform-specific handling""" print("Installing PyQt5...") # Try different PyQt5 variants packages_to_try = [ "PyQt5", "PyQt5-Qt5", "PyQt5-sip" ] for package in packages_to_try: print(f"Trying to install {package}...") if install_package(package): print(f"✅ Successfully installed {package}") return True else: print(f"❌ Failed to install {package}") return False def check_pyqt5(): """Check if PyQt5 is available""" try: import PyQt5 print("✅ PyQt5 is already installed") return True except ImportError: print("❌ PyQt5 not found") return False def main(): """Main installation function""" print("AccountForger - Dependency Installer") print("=" * 40) # Check Python version python_version = sys.version_info if python_version < (3, 7): print(f"❌ Python 3.7+ required, found {python_version.major}.{python_version.minor}") return False print(f"✅ Python {python_version.major}.{python_version.minor} detected") # Check/install PyQt5 if not check_pyqt5(): print("\nInstalling PyQt5...") if not install_pyqt5(): print("\n⚠️ PyQt5 installation failed!") print("Manual installation options:") print("1. pip install PyQt5") print("2. conda install pyqt (if using Anaconda)") print("3. Use system package manager (Linux)") print("\nAccountForger will still work with limited functionality") return False # Install other requirements other_packages = [ "requests", "selenium", "playwright", "beautifulsoup4", "lxml" ] print("\nInstalling other dependencies...") failed_packages = [] for package in other_packages: print(f"Installing {package}...") if install_package(package): print(f"✅ {package} installed") else: print(f"❌ {package} failed") failed_packages.append(package) if failed_packages: print(f"\n⚠️ Some packages failed to install: {failed_packages}") print("Try installing them manually with:") for package in failed_packages: print(f" pip install {package}") print("\n🚀 Installation complete!") print("You can now run: python main.py") return True if __name__ == "__main__": success = main() sys.exit(0 if success else 1)