Download check_dependencies.py from rastof9/fb: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/spaces/rastof9/fb/resolve/main/check_dependencies.py
- Command line
-
hf download hf://spaces/rastof9/fb/check_dependencies.py
-
curl -L -o check_dependencies.py https://huggingface.co/spaces/rastof9/fb/resolve/main/check_dependencies.py
2.34 kB
| #!/usr/bin/env python | |
| """ | |
| Dependency checker script for Facebook Ad Analytics. | |
| This script checks if all required dependencies are installed. | |
| """ | |
| import importlib | |
| import sys | |
| REQUIRED_PACKAGES = [ | |
| "flask", | |
| "flask_sqlalchemy", | |
| "flask_login", | |
| "flask_wtf", | |
| "flask_migrate", | |
| "werkzeug", | |
| "celery", | |
| "redis", | |
| "selenium", | |
| "transformers", | |
| "numpy", | |
| "cv2", # OpenCV | |
| "pytesseract", | |
| "gunicorn", | |
| "pytest", | |
| "prophet", | |
| "webdriver_manager", | |
| "psycopg2", | |
| "click", | |
| "dotenv", | |
| "ratelimit", | |
| ] | |
| OPTIONAL_PACKAGES = [ | |
| "torch", | |
| "tensorflow", | |
| "flax", | |
| ] | |
| def check_package(package_name): | |
| """Check if a package is installed.""" | |
| try: | |
| importlib.import_module(package_name) | |
| return True | |
| except ImportError: | |
| return False | |
| def main(): | |
| """Main function.""" | |
| print("Checking required dependencies...") | |
| missing_packages = [] | |
| for package in REQUIRED_PACKAGES: | |
| if not check_package(package): | |
| missing_packages.append(package) | |
| print(f"❌ {package} is not installed") | |
| else: | |
| print(f"✅ {package} is installed") | |
| print("\nChecking optional dependencies...") | |
| missing_optional = [] | |
| for package in OPTIONAL_PACKAGES: | |
| if not check_package(package): | |
| missing_optional.append(package) | |
| print(f"⚠️ {package} is not installed (optional)") | |
| else: | |
| print(f"✅ {package} is installed") | |
| if missing_packages: | |
| print(f"\n❌ {len(missing_packages)} required packages are missing:") | |
| print(" " + ", ".join(missing_packages)) | |
| print("\nPlease install them using:") | |
| print(f"pip install {' '.join(missing_packages)}") | |
| return 1 | |
| else: | |
| print("\n✅ All required packages are installed!") | |
| if missing_optional: | |
| print(f"\n⚠️ {len(missing_optional)} optional packages are missing:") | |
| print(" " + ", ".join(missing_optional)) | |
| print("\nYou may want to install them for full functionality:") | |
| print(f"pip install {' '.join(missing_optional)}") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) |