卓特视觉
网易AI大模型产品经理课程

ComfyUI-ArtGallery节点导入失败,提示找不到uploadImage.js怎么解决?

网易AI大模型产品经理课程

今天更新comfyui内核版本之后,之前运行正常的ComfyUI-ArtGallery插件突然无法导入,提示找不到uploadImage.js这个文件!具体错误信息如下:

FileNotFoundError: [Errno 2] No such file or directory: ‘G:\AIGC\ComfyUI-aki-v1.3\custom_nodes\ComfyUI-ArtGallery\../../web/extensions/core/uploadImage.js’

经过一番查找解决了这个报错,需要修改__init__.py这个文件中的相关代码,具体如下:

ComfyUI-ArtGallery节点导入失败,提示找不到uploadImage.js怎么解决?

①搜索def modify_js_file(file_path, new_content):将这段代码改为

def modify_js_file(file_path, new_content):
try:
with open(file_path, ‘r’, encoding=’utf-8′) as file:
content = file.read()

# Check if new content is already included
if “image_upload_artist” not in content:
insert_position = content.find(‘nodeData.input.required.upload = [“IMAGEUPLOAD”];’)
if insert_position != -1:
insert_position += len(‘nodeData.input.required.upload = [“IMAGEUPLOAD”];’)
content = content[:insert_position] + new_content + content[insert_position:]

# Backup the original file
backup_path = file_path + ‘.backup’
with open(backup_path, ‘w’, encoding=’utf-8′) as backup_file:
backup_file.write(content)

# Write modified content back to file
with open(file_path, ‘w’, encoding=’utf-8′) as file:
file.write(content)
print(f”File ‘{file_path}’ updated successfully.✅”)
else:
print(“Original code block not found.❌”)
else:
print(“File already contains the necessary modifications.✅”)
except Exception as e:
print(f”An error occurred: {e}”)

②搜索def modify_py_file(file_path, new_content, search_line, function_content, search_function):将这段代码改为:

def modify_py_file(file_path, new_content, search_line, function_content, search_function):
try:
with open(file_path, ‘r’, encoding=’utf-8′) as file:
lines = file.readlines()

# Prepare key lines of new content and function content for comparison
new_content_key_line = new_content.strip().split(‘\n’)[0]function_content_key_line = function_content.strip().split(‘\n’)[0]

# Check if new content already exists
if new_content_key_line not in “”.join(lines):
for index, line in enumerate(lines):
if search_line in line:
lines.insert(index + 1, new_content)
break

# Check if function modification already exists
if function_content_key_line not in “”.join(lines):
function_start = False
for index, line in enumerate(lines):
if search_function in line:
function_start = True
if function_start and “return None” in line:
lines.insert(index, function_content)
break

# Backup the original file
backup_path = file_path + ‘.backup’
with open(backup_path, ‘w’, encoding=’utf-8′) as backup_file:
backup_file.writelines(lines)

# Write back the modified content
with open(file_path, ‘w’, encoding=’utf-8′) as file:
file.writelines(lines)
print(f”File ‘{file_path}’ updated successfully.✅”)

except Exception as e:
print(f”An error occurred: {e}”)

③搜索def modify_wedgets_js_file(file_path, new_content, new_content_2):将这段代码改为

def modify_wedgets_js_file(file_path, new_content, new_content_2):
try:
with open(file_path, ‘r’, encoding=’utf-8′) as file:
content = file.read()

# Check if the file already contains the content to be added
if “ARTISTS_IMAGEUPLOAD” not in content:
# Find the position of the original code
insert_position = content.find(‘return (display===”slider”) ? “slider” : “number”‘)
if insert_position != -1:
# Insert new code after the original code
insert_position += len(‘return (display===”slider”) ? “slider” : “number”‘)
content = content[:insert_position] + new_content + content[insert_position:]

insert_position_2 = content.find(‘return { widget: uploadWidget };’)
if insert_position_2 != -1:
# Insert new code after the original code
insert_position_2 += len(‘return { widget: uploadWidget };’)
content = content[:insert_position_2] + new_content_2 + content[insert_position_2:]

# Backup the original file
backup_path = file_path + ‘.backup’
with open(backup_path, ‘w’, encoding=’utf-8′) as backup_file:
backup_file.write(content)

# Write back the file
with open(file_path, ‘w’, encoding=’utf-8′) as file:
file.write(content)
print(f”File ‘{file_path}’ updated successfully.✅”)
else:
print(“Original code block not found.❌”)
else:
print(“File already contains the necessary modifications.✅”)
except Exception as e:
print(f”An error occurred: {e}”)

完成之后保存,然后重启你的comfyui就可以正常运行插件了!

© 版权声明

相关文章