Stability-AI / stable-audio-tools

Generative models for conditional audio generation
MIT License
2.5k stars 229 forks source link

ModuleNotFoundError: No module named 'packaging' from pip install stable-audio-tools #74

Open w84death opened 3 months ago

w84death commented 3 months ago
 Downloading flash_attn-2.5.9.post1.tar.gz (2.6 MB)
     ---------------------------------------- 2.6/2.6 MB 6.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "C:\StableAudio\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\StableAudio\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\StableAudio\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Krzysztof Jankowski\AppData\Local\Temp\pip-build-env-e_t_1lmm\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Krzysztof Jankowski\AppData\Local\Temp\pip-build-env-e_t_1lmm\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\Krzysztof Jankowski\AppData\Local\Temp\pip-build-env-e_t_1lmm\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "C:\Users\Krzysztof Jankowski\AppData\Local\Temp\pip-build-env-e_t_1lmm\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 9, in <module>
      ModuleNotFoundError: No module named 'packaging'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Same error on:

Both using venv.

hushaudio commented 3 months ago

The issue is with your systems compatibility with the package flash_atn

If it can’t build the wheel it means something is not compatible. On windows, WSL uses Ubuntu which should fix the issue, but I haven’t worked on windows 10 just windows 11 which uses WSL2. You should be looking into flash_attn tho and compatibility with your system.

hushaudio commented 3 months ago

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

Skquark commented 3 months ago

I'm also getting this issue trying to install on Windows in a venv. I've tried switching to multiple version of packaging and setuptools, but just can't find the key to installing it. Also having a bunch of issues trying to install stable-audio-tools on Google Colab, getting multiple conflicts like numpy, argparse, protobuf, cuda, etc. Then it needs to restart session, which I do and try installing again, but it still doesn't work, asking to restart again. Hate dealing with versioning conflicts, especially when trying to integrate in an existing project that has many other pinned dependencies with packages we have no control over..

w84death commented 3 months ago

@hushaudio thanks! unfortunately I ran into same problem in the end.

fred-dev commented 3 months ago

I'm also getting this issue trying to install on Windows in a venv. I've tried switching to multiple version of packaging and setuptools, but just can't find the key to installing it.

Also having a bunch of issues trying to install stable-audio-tools on Google Colab, getting multiple conflicts like numpy, argparse, protobuf, cuda, etc. Then it needs to restart session, which I do and try installing again, but it still doesn't work, asking to restart again. Hate dealing with versioning conflicts, especially when trying to integrate in an existing project that has many other pinned dependencies with packages we have no control over..

You can use a venv in google colab and this will get rid of the issues you have there. Miniconda works fine for me. The setup is marginally longer but not a big deal.

As for the flash attention, this library has specific hardware requirements, it will give errors if your hardware does not support flash attention. I have seen some cases where the code designed to pickup the hardware (GPU) version and deal with flash attention initialisation does not work. I have made a temporary workaround by forcing flash attention off in the checks. I suspect the driver version reports are also linked to cuda versions and this is why the detection does not always report correctly, but I have not had time to check this.

A temporary hack is to search the flash attention initialisation and force it off. Alternatively some research into version reporting is needed to make this more reliable.

You will find that on later hardware you will not have this issue.

0xdevalias commented 3 months ago

See also:

Abhijitjimmi commented 3 months ago

edit the line with this import packaging its no more from pkg_resources

joerg-knitter commented 2 months ago

I get the same error message on Windows 11 with Python 3.12.4, using a clean venv with setuptools downgraded to 69.5.1. Where should I edit the import packaging line?

EDIT: Works when I use Python 3.8.10 instead with downgraded setuptools, but I would prefer to use the latest versions. And CUDA is not found (yet), but this is offtopic...

0xdevalias commented 2 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: