Open shsotoudegan opened 2 months ago
my guess is that your current work directory is not at webui root
for a test modify https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/1c0a0c4c26f78c32095ebc7f8af82f5c04fca8c0/modules/launch_utils.py#L234 to
env['PYTHONPATH'] = f"{os.path.dirname(os.path.dirname(__file__))}{os.pathsep}{env.get('PYTHONPATH', '')}"
os.path.abspath('.')
-> os.path.dirname(os.path.dirname(__file__))
and if it's this case I think this is more of a user instance configuration error
webui is build on the assumption that the cwd is webui root
os.path.abspath('.')is the cwd and will be prepend to
PYTHONPATH` when running install.py
this will allow install.py to access webui scripts like importing launch
but if you cwd is not webui root, import launch will fail
the the above fix for you this is most likely what's happening
if this is fixed is applied they might still be other issues as they might be other places in code that makes the assumption that cwd is webui root
my guess is that your current work directory is not at webui root
for a test modify
to
env['PYTHONPATH'] = f"{os.path.dirname(os.path.dirname(__file__))}{os.pathsep}{env.get('PYTHONPATH', '')}"
os.path.abspath('.')
->os.path.dirname(os.path.dirname(__file__))
and if it's this case I think this is more of a user instance configuration error
webui is build on the assumption that the cwd is webui root os.path.abspath('.')
is the cwd and will be prepend to
PYTHONPATH` when running install.py this will allow install.py to access webui scripts like importing launch but if you cwd is not webui root, import launch will fail the the above fix for you this is most likely what's happeningif this is fixed is applied they might still be other issues as they might be other places in code that makes the assumption that cwd is webui root
Thanks for you're recommend @w-e-w . I created a pull request #15704 for this issue.
In some cases, for example when A1111 uses in dependencies of another project ( for example get access to A1111 by API in replicate/cog) user isn't in A1111 root directory. User uses A1111 from another project root and needs to install some extensions that uses A1111 modules. that cases that extensions like ControlNet fail in installation process.
Is there an existing issue for this?
What would your feature do ?
There is a complete conversation in https://github.com/Mikubill/sd-webui-controlnet/issues/2836 issue and https://github.com/Mikubill/sd-webui-controlnet/pull/2839 pull request on ControlNet repo. Implementation of launch_utils.run_extension_installer can be better. but that can effect All other extensions installation. https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/1c0a0c4c26f78c32095ebc7f8af82f5c04fca8c0/modules/launch_utils.py#L227-L240
I know that
relative import beyond the top-level package
in python not allowed. but I think with a better implementation of this function (which I don't know how to do that) we can help extension contributors think about something else.Proposed workflow
relative import beyond the top-level package
problem.Additional information
this can help extensions for better contribution to project.