- 调整自定义节点文件结构,使用 `nodes.py` 和 `__init__.py` 组织代码 - 增加导入和运行时的详细日志输出,便于调试 - 为图像转换、加密和文件写入等关键步骤添加异常捕获与打印 - 新增 `install.py` 脚本自动安装依赖 - 更新 README 文档说明新的目录结构和使用方式 - 移除旧的示例脚本引用,统一通过模块导入调用核心功能
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
def ensure_dependencies():
|
|
"""Ensure all dependencies are installed in the correct Python environment"""
|
|
# Get the directory where this script is located
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
# Get Python executable path from ComfyUI's environment
|
|
python = sys.executable
|
|
|
|
print("Installing dependencies...")
|
|
|
|
try:
|
|
# Install dependencies using pip in the correct Python environment
|
|
subprocess.check_call([python, '-m', 'pip', 'install', '-r',
|
|
os.path.join(script_dir, 'requirements.txt')])
|
|
print("Dependencies installed successfully!")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"Error installing dependencies: {e}")
|
|
print("Please try installing them manually using:")
|
|
print(f"'{python} -m pip install -r requirements.txt'")
|
|
except Exception as e:
|
|
print(f"An unexpected error occurred: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
ensure_dependencies() |