87 lines
2.6 KiB
Python
87 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
检查打包依赖是否完整
|
|
"""
|
|
|
|
import sys
|
|
import importlib
|
|
from pathlib import Path
|
|
|
|
def check_import(module_name, description=""):
|
|
"""检查模块是否可以导入"""
|
|
try:
|
|
module = importlib.import_module(module_name)
|
|
version = getattr(module, '__version__', 'unknown')
|
|
print(f"✓ {module_name} (v{version}) - {description}")
|
|
return True
|
|
except ImportError as e:
|
|
print(f"✗ {module_name} - {description} - ERROR: {e}")
|
|
return False
|
|
|
|
def main():
|
|
print("打包依赖检查")
|
|
print("=" * 50)
|
|
|
|
# 检查核心依赖
|
|
dependencies = [
|
|
('PySide6', 'GUI框架'),
|
|
('pandas', 'InfluxDB查询中使用的数据处理库'),
|
|
('numpy', 'pandas的依赖库'),
|
|
('influxdb_client', 'InfluxDB客户端'),
|
|
('matplotlib', '图表生成'),
|
|
('docx', 'Word文档处理 (python-docx)'),
|
|
('pymodbus', 'Modbus通信'),
|
|
('sqlite3', '数据库支持'),
|
|
('json', 'JSON处理'),
|
|
('datetime', '时间处理'),
|
|
('logging', '日志记录'),
|
|
('pathlib', '路径处理'),
|
|
]
|
|
|
|
success_count = 0
|
|
total_count = len(dependencies)
|
|
|
|
for module_name, description in dependencies:
|
|
if check_import(module_name, description):
|
|
success_count += 1
|
|
|
|
print("\n" + "=" * 50)
|
|
print(f"检查结果: {success_count}/{total_count} 个依赖可用")
|
|
|
|
if success_count == total_count:
|
|
print("✅ 所有依赖都可用,可以进行打包")
|
|
else:
|
|
print("❌ 有依赖缺失,请先安装缺失的包")
|
|
print("\n安装命令:")
|
|
print("pip install -r requirements.txt")
|
|
|
|
# 检查spec文件
|
|
print("\n检查PyInstaller配置文件:")
|
|
spec_files = [
|
|
'docx_creator.spec',
|
|
'docx_creator_fixed.spec',
|
|
'DocxCreatorPro.spec'
|
|
]
|
|
|
|
for spec_file in spec_files:
|
|
spec_path = Path(spec_file)
|
|
if spec_path.exists():
|
|
print(f"✓ {spec_file} 存在")
|
|
|
|
# 检查是否包含pandas
|
|
content = spec_path.read_text(encoding='utf-8')
|
|
if "'pandas'" in content:
|
|
print(f" ✓ {spec_file} 包含 pandas")
|
|
else:
|
|
print(f" ✗ {spec_file} 缺少 pandas")
|
|
|
|
if "'numpy'" in content:
|
|
print(f" ✓ {spec_file} 包含 numpy")
|
|
else:
|
|
print(f" ✗ {spec_file} 缺少 numpy")
|
|
else:
|
|
print(f"✗ {spec_file} 不存在")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|