58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
"""
|
|
检查所有依赖是否已安装
|
|
"""
|
|
import sys
|
|
|
|
def check_dependency(module_name, import_statement):
|
|
"""检查单个依赖"""
|
|
try:
|
|
exec(import_statement)
|
|
print(f"✓ {module_name}: 已安装")
|
|
return True
|
|
except ImportError as e:
|
|
print(f"✗ {module_name}: 未安装 - {str(e)}")
|
|
return False
|
|
|
|
def main():
|
|
"""主函数"""
|
|
print("="*60)
|
|
print("检查依赖安装情况")
|
|
print("="*60)
|
|
print()
|
|
|
|
dependencies = [
|
|
("Flask", "from flask import Flask"),
|
|
("Flask-CORS", "from flask_cors import CORS"),
|
|
("Flasgger", "from flasgger import Swagger"),
|
|
("PyMySQL", "import pymysql"),
|
|
("python-dotenv", "from dotenv import load_dotenv"),
|
|
("Requests", "import requests"),
|
|
("python-docx", "from docx import Document"),
|
|
("MinIO", "from minio import Minio"),
|
|
("openpyxl", "import openpyxl"),
|
|
]
|
|
|
|
results = []
|
|
for name, import_stmt in dependencies:
|
|
results.append(check_dependency(name, import_stmt))
|
|
|
|
print()
|
|
print("="*60)
|
|
installed = sum(results)
|
|
total = len(results)
|
|
print(f"已安装: {installed}/{total}")
|
|
|
|
if installed < total:
|
|
print("\n缺少的依赖,请运行:")
|
|
print(" pip install -r requirements.txt")
|
|
return False
|
|
else:
|
|
print("\n✓ 所有依赖已安装!")
|
|
return True
|
|
|
|
if __name__ == '__main__':
|
|
success = main()
|
|
sys.exit(0 if success else 1)
|
|
|
|
|