[GH-ISSUE #55] Error running on colab webui automatic111 as an extension. #41

Closed
opened 2026-10-30 21:17:44 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @imesha10 on GitHub (Oct 31, 2022).
Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/55

Quick Description how I got this error.

I installed this as instructed in the readme as an extension. Then once the webui is in final stages of loading up this error pops up. (note that the webui still functions and I can produce images, just the extention keeps spitting out errors constantly, the error following is the first error I get").

Error Log

Error loading script: tag_autocomplete_helper.py
Traceback (most recent call last):
File "/content/stable-diffusion-webui/modules/scripts.py", line 168, in load_scripts
exec(compiled, module.dict)
File "/content/stable-diffusion-webui/extensions/tag-autocomplete/scripts/tag_autocomplete_helper.py", line 24, in
TAGS_PATH = get_tags_base_path()
File "/content/stable-diffusion-webui/extensions/tag-autocomplete/scripts/tag_autocomplete_helper.py", line 18, in get_tags_base_path
if (script_path.is_relative_to(EXT_PATH)):
AttributeError: 'PosixPath' object has no attribute 'is_relative_to'

My guess on what this could be

Looking at the error message I think the issue is script_path is not initialized. I looked at the code and the following is where its initialized.
github.com/DominikDoom/a1111-sd-webui-tagcomplete@372a499615/scripts/tag_autocomplete_helper.py (L16-L18)

Originally created by @imesha10 on GitHub (Oct 31, 2022). Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/55 ## Quick Description how I got this error. I installed this as instructed in the readme as an extension. Then once the webui is in final stages of loading up this error pops up. (note that the webui still functions and I can produce images, just the extention keeps spitting out errors constantly, the error following is the first error I get"). ## Error Log Error loading script: tag_autocomplete_helper.py Traceback (most recent call last): File "/content/stable-diffusion-webui/modules/scripts.py", line 168, in load_scripts exec(compiled, module.__dict__) File "/content/stable-diffusion-webui/extensions/tag-autocomplete/scripts/tag_autocomplete_helper.py", line 24, in <module> TAGS_PATH = get_tags_base_path() File "/content/stable-diffusion-webui/extensions/tag-autocomplete/scripts/tag_autocomplete_helper.py", line 18, in get_tags_base_path if (script_path.is_relative_to(EXT_PATH)): AttributeError: 'PosixPath' object has no attribute 'is_relative_to' ## My guess on what this could be Looking at the error message I think the issue is script_path is not initialized. I looked at the code and the following is where its initialized. https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/blob/372a499615311ef54ad5332525505bf87d854007/scripts/tag_autocomplete_helper.py#L16-L18
Author
Owner

@DominikDoom commented on GitHub (Oct 31, 2022):

The error states that is_relative_to can't be found. This is a python version problem, that attribute was only added in python 3.9. For local it isn't a problem since 3.10.6 is recommended for the webui, but it seems Colab is running 3.7.x by default, which I wasn't aware of. You can technically change the version since you have full access to the instance Debian backend, but it seems pretty annoying to do.

One workaround is the option used in #45, which I originally didn't want to use, but now that I know it's needed on colab maybe I should use it after all or add a version check / fallback to it.

<!-- gh-comment-id:1296685336 --> @DominikDoom commented on GitHub (Oct 31, 2022): The error states that is_relative_to can't be found. This is a python version problem, that attribute was only added in python 3.9. For local it isn't a problem since 3.10.6 is recommended for the webui, but it seems Colab is running 3.7.x by default, which I wasn't aware of. You can technically change the version since you have full access to the instance Debian backend, but it seems pretty annoying to do. One workaround is the option used in #45, which I originally didn't want to use, but now that I know it's needed on colab maybe I should use it after all or add a version check / fallback to it.
Author
Owner

@imesha10 commented on GitHub (Oct 31, 2022):

Wow lol you are right, I forgot about the python version requirment. Thanks, I managed to get around it somehow. By the way I was looking at the code and looking at what that was trying to do.

github.com/DominikDoom/a1111-sd-webui-tagcomplete@372a499615/scripts/tag_autocomplete_helper.py (L7-L24)

From what I can see line 8-24 is trying to get the tags base path. I was looking through what the scripts.basedir() does in the documentation(code) from automatic111webui and found this.

def basedir():
    """returns the base directory for the current script. For scripts in the main scripts directory,
    this is the main directory (where webui.py resides), and for scripts in extensions directory
    (ie extensions/aesthetic/script/aesthetic.py), this is extension's directory (extensions/aesthetic)
    """
    return current_basedir

I might be wrong but doesn't both of these produce the same result without the check?
If it was not installed as an extension then it would return .../stable-diff-webui/.
If it was an extension it would return .../stable-diff-webui/extensions/a111-sd-webui-tagcomplete/.
Either way when appending 'tags' to scripts.basedir(), you get the right path.

import os

def get_tags_base_path():
    return os.path.join(scripts.basedir(), "tags")
(I have not tested the code)

Anyways thanks for the help.

<!-- gh-comment-id:1296829812 --> @imesha10 commented on GitHub (Oct 31, 2022): Wow lol you are right, I forgot about the python version requirment. Thanks, I managed to get around it somehow. By the way I was looking at the code and looking at what that was trying to do. https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/blob/372a499615311ef54ad5332525505bf87d854007/scripts/tag_autocomplete_helper.py#L7-L24 From what I can see line 8-24 is trying to get the tags base path. I was looking through what the scripts.basedir() does in the documentation(code) from automatic111webui and found this. ```python def basedir(): """returns the base directory for the current script. For scripts in the main scripts directory, this is the main directory (where webui.py resides), and for scripts in extensions directory (ie extensions/aesthetic/script/aesthetic.py), this is extension's directory (extensions/aesthetic) """ return current_basedir ``` I might be wrong but doesn't both of these produce the same result without the check? If it was not installed as an extension then it would return .../stable-diff-webui/. If it was an extension it would return .../stable-diff-webui/extensions/a111-sd-webui-tagcomplete/. Either way when appending 'tags' to scripts.basedir(), you get the right path. ```python import os def get_tags_base_path(): return os.path.join(scripts.basedir(), "tags") ``` ###### (I have not tested the code) Anyways thanks for the help.
Author
Owner

@DominikDoom commented on GitHub (Oct 31, 2022):

I might be wrong but doesn't both of these produce the same result without the check?

Huh I actually never thought about that, since it wasn't mentioned in the Wiki about extension development.
But from a quick look it seems like it would work. I'll try it out later.

<!-- gh-comment-id:1296835493 --> @DominikDoom commented on GitHub (Oct 31, 2022): > I might be wrong but doesn't both of these produce the same result without the check? Huh I actually never thought about that, since it wasn't mentioned in the Wiki about extension development. But from a quick look it seems like it would work. I'll try it out later.
Author
Owner

@DominikDoom commented on GitHub (Oct 31, 2022):

You were correct, this makes the whole check unnecessary. Thanks for the pointer!
That should also make it work with Python 3.7 out of the box.

<!-- gh-comment-id:1296864157 --> @DominikDoom commented on GitHub (Oct 31, 2022): You were correct, this makes the whole check unnecessary. Thanks for the pointer! That should also make it work with Python 3.7 out of the box.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DominikDoom/a1111-sd-webui-tagcomplete#41
No description provided.