thomasasfk / sd-webui-aspect-ratio-helper

Simple extension to easily maintain aspect ratio while changing dimensions. Install via the extensions tab on the AUTOMATIC1111 webui.
https://github.com/thomasasfk/sd-webui-aspect-ratio-helper.git
415 stars 66 forks source link

When webui starting, got this TypeError: 'type' object is not subscriptable #20

Closed chouti closed 1 year ago

chouti commented 1 year ago
Error loading script: sd_webui_aspect_ratio_helper.py
Traceback (most recent call last):
  File "/home/sdw/stable-diffusion-webui/modules/scripts.py", line 248, in load_scripts
    script_module = script_loading.load_module(scriptfile.path)
  File "/home/sdw/stable-diffusion-webui/modules/script_loading.py", line 11, in load_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/sdw/stable-diffusion-webui/extensions/sd-webui-aspect-ratio-helper/scripts/sd_webui_aspect_ratio_helper.py", line 1, in <module>
    from aspect_ratio_helper.main import AspectRatioStepScript
  File "/home/sdw/stable-diffusion-webui/extensions/sd-webui-aspect-ratio-helper/aspect_ratio_helper/main.py", line 6, in <module>
    import aspect_ratio_helper._settings as _settings
  File "/home/sdw/stable-diffusion-webui/extensions/sd-webui-aspect-ratio-helper/aspect_ratio_helper/_settings.py", line 4, in <module>
    import aspect_ratio_helper._components as _components
  File "/home/sdw/stable-diffusion-webui/extensions/sd-webui-aspect-ratio-helper/aspect_ratio_helper/_components.py", line 9, in <module>
    import aspect_ratio_helper._util as _util
  File "/home/sdw/stable-diffusion-webui/extensions/sd-webui-aspect-ratio-helper/aspect_ratio_helper/_util.py", line 6, in <module>
    def safe_opt_util(shared_opts, key, default_key_map: dict[str, object]):
TypeError: 'type' object is not subscriptable
thomasasfk commented 1 year ago

Thanks for raising, have removed the erroneous typing in https://github.com/thomasasfk/sd-webui-aspect-ratio-helper/pull/21

Out of curiosity, which python version were you using? I didn't get this error locally.

thomasasfk commented 1 year ago

I think this was because you were using a version less than 3.9: https://github.com/thomasasfk/sd-webui-aspect-ratio-helper/pull/22

If possible, could you try to use 3.10.6?

This is what is specified in A111's webui: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/f36ba9949a64fd35a81369e4ec7107b1b87ef7fb/README.md?plain=1#L104

thomasasfk commented 1 year ago

As of https://github.com/thomasasfk/sd-webui-aspect-ratio-helper/pull/22, we only support python version's 3.10 & 3.11 - I'd recommend switching to 3.10.6, as that's what's specified by A111's webui.