Skip to content

ImportError: cannot import name 'packaging' from 'pkg_resources' from run_gradio.py #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
YoungPhlo opened this issue May 27, 2024 · 3 comments

Comments

@YoungPhlo
Copy link

Traceback:

(venv) PS stable-audio-tools> python run_gradio.py --ckpt-path ./models/model.ckpt --model-config ./models/model_config.json
Traceback (most recent call last):
  File "run_gradio.py", line 2, in <module>
    from stable_audio_tools.interface.gradio import create_ui
  File "stable-audio-tools\stable_audio_tools\interface\gradio.py", line 14, in <module>
    from ..inference.generation import generate_diffusion_cond, generate_diffusion_uncond
  File "stable-audio-tools\stable_audio_tools\inference\generation.py", line 8, in <module>
    from .sampling import sample, sample_k
  File "stable-audio-tools\stable_audio_tools\inference\sampling.py", line 5, in <module>
    import k_diffusion as K
  File "stable-audio-tools\venv\lib\site-packages\k_diffusion\__init__.py", line 1, in <module>
    from . import augmentation, config, evaluation, external, gns, layers, models, sampling, utils
  File "stable-audio-tools\venv\lib\site-packages\k_diffusion\evaluation.py", line 6, in <module>
    import clip
  File "stable-audio-tools\venv\lib\site-packages\clip\__init__.py", line 1, in <module>
    from .clip import *
  File "stable-audio-tools\venv\lib\site-packages\clip\clip.py", line 6, in <module>
    from pkg_resources import packaging
ImportError: cannot import name 'packaging' from 'pkg_resources' (stable-audio-tools\venv\lib\site-packages\pkg_resources\__init__.py)

They're having the same issue over on AUTOMATIC1111/stable-diffusion-webui#15863

Something about the setuptools==70.0.0 release broke pkg_resources and it looks like there are no plans to fix it... Not sure where that leaves clip

The command that worked for me is
python -m pip install setuptools==69.5.1

(with the stable-audio-tools venv activated)

I can run python run_gradio.py plus arguments and it works after downgrading.

@0xdevalias
Copy link

@0xdevalias
Copy link

You could also check how NanoCoder installed flash-attn mentioned at the end of this post

The relevant part seems to be related to setuptools:

Thanks! a clean env solved it.

On a clean env, I additionally had to install

# ..snip..

# for packaging error `cannot import name 'packaging' from 'pkg_resources'`
pip install -U packaging
pip install setuptools==69.5.1

# ..snip..

Originally posted by @NanoCode012 in #73 (comment)

Following from that, to the official setuptools GitHub repo, and searching for the error there, leads me to issues such as these:

So as I read that, the solutions are either to:

Originally posted by @0xdevalias in #74 (comment)

@skirdey
Copy link

skirdey commented Jun 27, 2024

After installing OpenAI's clip it works

pip install git+https://github.com/openai/CLIP.git

zqevans added a commit that referenced this issue Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants