diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

ImportError from 'diffusers'

Open xABSTRACTORx opened this issue 1 year ago • 27 comments

6 import PIL 7 ----> 8 from diffusers import StableDiffusionInpaintPipeline 9 10 def download_image(url):

ImportError: cannot import name 'StableDiffusionInpaintPipeline' from 'diffusers' (/usr/local/lib/python3.7/dist-packages/diffusers/init.py)

xABSTRACTORx avatar Sep 01 '22 04:09 xABSTRACTORx

+1

krrishdholakia avatar Sep 01 '22 05:09 krrishdholakia

Hi there!

I think that requires the main branch. Can you try installing using the following instead?

pip install -U git+https://github.com/huggingface/diffusers

pcuenca avatar Sep 01 '22 08:09 pcuenca

+1

I get the same error on huggingface Space, while trying to import 'StableDiffusionImg2ImgPipeline' instead of 'StableDiffusionPipeline'

import_error_stableDiff

fffiloni avatar Sep 01 '22 14:09 fffiloni

+1 Cant import any of these.

When I look in the init file, only the default pipe is available. So the others like img2img didn't make it in.

chengyjonathan avatar Sep 02 '22 14:09 chengyjonathan

cc: @anton-l @patrickvonplaten

krrishdholakia avatar Sep 02 '22 17:09 krrishdholakia

+1 Also having this issue with StableDiffusionImg2ImgPipeline and the inpainting equivalent

BenjaminIrwin avatar Sep 02 '22 18:09 BenjaminIrwin

Hey everybody,

Could you please install diffusers as stated by @pcuenca to solve this problem:

pip install -U git+https://github.com/huggingface/diffusers

?

We will probably make a new diffusers version by the end of next week to include StableDiffusionImg2ImgPipeline in main

patrickvonplaten avatar Sep 02 '22 18:09 patrickvonplaten

For huggingface space, you need to import diffusers through github pip install, as i did in a requirements.txt file ;)

39E6A9CA-83CF-470F-A962-BA5DE06F9BE3

fffiloni avatar Sep 02 '22 18:09 fffiloni

for example, If you are installing diffusers from a clone of CompVis/stable-diffusion, you will get this error.

The file that exists on github is newer than the file that can be installed with pip, but it is the same version 0.2.4, so it cannot be upgraded using pip.

If you have installed the older version using pip, you will need to uninstall it once.

pip uninstall diffusers

then

pip install -U git+https://github.com/huggingface/diffusers

webbigdata-jp avatar Sep 03 '22 11:09 webbigdata-jp

This is still not working for me. I followed the above comment to uninstall the old diffusers then install from git.

>>> from diffusers import StableDiffusionPipeline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alan/anaconda3/lib/python3.8/site-packages/diffusers/__init__.py", line 12, in <module>
    from .configuration_utils import ConfigMixin
  File "/home/alan/anaconda3/lib/python3.8/site-packages/diffusers/configuration_utils.py", line 26, in <module>
    from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError
ImportError: cannot import name 'EntryNotFoundError' from 'huggingface_hub.utils' (/home/alan/anaconda3/lib/python3.8/site-packages/huggingface_hub/utils/__init__.py)

apcode avatar Sep 12 '22 16:09 apcode

Hey @apcode,

Could you run diffusers-cli env and show what versions you're using ? E.g. what Python version, what torch version, on what platform etc...

patrickvonplaten avatar Sep 13 '22 13:09 patrickvonplaten

(base) alan@linux-beast:~/Workspace/diffusers -[] $ diffusers-cli env
Traceback (most recent call last):
  File "/home/alan/anaconda3/bin/diffusers-cli", line 5, in <module>
    from diffusers.commands.diffusers_cli import main
  File "/home/alan/anaconda3/lib/python3.8/site-packages/diffusers/__init__.py", line 12, in <module>
    from .configuration_utils import ConfigMixin
  File "/home/alan/anaconda3/lib/python3.8/site-packages/diffusers/configuration_utils.py", line 26, in <module>
    from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError
ImportError: cannot import name 'EntryNotFoundError' from 'huggingface_hub.utils' (/home/alan/anaconda3/lib/python3.8/site-packages/huggingface_hub/utils/__init__.py)

That's no good :-) I am using anaconda and have run conda update conda python 3.8.13 torch==1.12.1 transformers==4.10.2

uname -a Linux linux-beast 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

apcode avatar Sep 13 '22 14:09 apcode

It is possible that you can upgrade transformers? Maybe to 4.21? :-)

patrickvonplaten avatar Sep 13 '22 15:09 patrickvonplaten

upgraded to transformers==4.21.3 still happens.

apcode avatar Sep 13 '22 15:09 apcode

Okey sorry, next try.

Could you update huggingface_hub by running:

pip install --upgrade huggingface_hub

patrickvonplaten avatar Sep 13 '22 16:09 patrickvonplaten

huggingface-hub==0.9.1

Still no joy. I appreciate the help btw

apcode avatar Sep 13 '22 16:09 apcode

Hmm that's weird I'm pretty sure it should work with huggingface_hub==0.9.1. Also tried reproducing it myself and I'm not able to.

Could you maybe try uninstalling huggingface_hub both with:

pip uninstall huggingface_hub

and

conda remove huggingface_hub

and then re-installing it (just to make sure we don't have multiple version of huggingface-hub used).

Also gently pinging @Wauplin and @LysandreJik here in case they've seen this hub error before

patrickvonplaten avatar Sep 13 '22 23:09 patrickvonplaten

Hi there :wave: I can confirm that EntryNotFoundError is new in huggingface_hub so latest released version must be installed (v0.9.1). @apcode could you run the following snippet to be sure that the imported lib is indeed the one we think ?

import huggingface_hub

print(huggingface_hub.__version__)

(and I agree with @patrickvonplaten for a complete uninstall/reinstall, just in case. I don't what else could be wrong :grimacing: ).

Wauplin avatar Sep 14 '22 12:09 Wauplin

Python 3.8.13 (default, Mar 28 2022, 11:38:47) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import huggingface_hub
>>> print(huggingface_hub.__version__)
0.2.1

That's quite a different version installed. So I tried:

$ conda search huggingface_hub
Loading channels: done
# Name                       Version           Build  Channel             
huggingface_hub               0.0.17    pyhd3eb1b0_0  pkgs/main           
huggingface_hub                0.2.1    pyhd3eb1b0_0  pkgs/main  

apcode avatar Sep 14 '22 18:09 apcode

Ahh, I don't think we have huggingface_hub released on conda forge maybe? cc @LysandreJik here as well

patrickvonplaten avatar Sep 14 '22 20:09 patrickvonplaten

Hmm, huggingface_hub is released on conda-forge but there seem to be older versions on the main channel as well (see https://anaconda.org/search?q=huggingface_hub).

@LysandreJik is there a way to deprecate/yank/delete those old versions to avoid confusion ?

Screenshot

Wauplin avatar Sep 15 '22 08:09 Wauplin

Ah indeed, it seems the main + anaconda channels have not upgraded. Let me take a look.

LysandreJik avatar Sep 15 '22 11:09 LysandreJik

It's unlikely that we'll get these versions to upgrade as the anaconda main channel tries to have all their supported packages be compatible with one another; so spending time to get them to upgrade is likely a waste of time given that we would need to do so every time there is an update in one of our libraries.

I'd favor educating users to use conda-forge as is done currently in the README where you currently mention conda install -c conda-forge diffusers.

@apcode, could you please try with

conda install -c conda-forge huggingface_hub ? It should uninstall your currently installed version and install the new one:

The following packages will be UPDATED:

  ca-certificates    pkgs/main::ca-certificates-2022.07.19~ --> conda-forge::ca-certificates-2022.9.14-ha878542_0
  certifi            pkgs/main/linux-64::certifi-2022.6.15~ --> conda-forge/noarch::certifi-2022.9.14-pyhd8ed1ab_0
  huggingface_hub    pkgs/main::huggingface_hub-0.2.1-pyhd~ --> conda-forge::huggingface_hub-0.9.1-pyhd8ed1ab_0

Thank you!

LysandreJik avatar Sep 15 '22 12:09 LysandreJik

Thanks for investigating @LysandreJik ! Do you think we can completely remove it from the main channel or this is not something we don't have a hand on ?

Wauplin avatar Sep 15 '22 12:09 Wauplin

That's not something we have a hand on: that's managed by the anaconda team. IIUC they handle package versions so that there will never be dependency issues and dependency conflicts. If they were to remove support for huggingface_hub, then they'd likely have a myriad of dependency issues, so I'd say that it's very unlikely to happen.

LysandreJik avatar Sep 15 '22 13:09 LysandreJik

Ok, too bad :'(

Wauplin avatar Sep 15 '22 13:09 Wauplin

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Oct 09 '22 15:10 github-actions[bot]