Stability-AI / stable-audio-tools

Generative models for conditional audio generation
MIT License
2.73k stars 258 forks source link

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

Open YoungPhlo opened 5 months ago

YoungPhlo commented 5 months ago

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 https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/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 commented 5 months ago

See also:

0xdevalias commented 5 months ago

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 https://github.com/Stability-AI/stable-audio-tools/issues/73#issuecomment-2151566689

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 https://github.com/Stability-AI/stable-audio-tools/issues/74#issuecomment-2164143964

skirdey commented 4 months ago

After installing OpenAI's clip it works

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