I cant fix these errors. Can anybody help me?:)

Hi, i got error when i was trying install requirements. The error is:

        thinc/backends/numpy_ops.cpp: In function 'int __Pyx_TraceSetupAndCall(PyCodeObject**, PyFrameObject**, PyThreadState*, const char*, const char*, int)':
        thinc/backends/numpy_ops.cpp:2408:34: hata: '_PyCFrame' {aka 'struct _PyCFrame'} has no member named 'use_tracing'
         2408 |      (unlikely((tstate)->cframe->use_tracing) &&\
              |                                  ^~~~~~~~~~~
        thinc/backends/numpy_ops.cpp:1001:43: bilgi: in definition of macro 'unlikely'
         1001 |   #define unlikely(x) __builtin_expect(!!(x), 0)
              |                                           ^
        thinc/backends/numpy_ops.cpp:53763:16: bilgi: in expansion of macro '__Pyx_IsTracing'
        53763 |         return __Pyx_IsTracing(tstate, 0, 0) && retval;
              |                ^~~~~~~~~~~~~~~
        error: command '/usr/bin/gcc' failed with exit code 1
        [end of output]
  
    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for thinc
  Failed to build thinc
  ERROR: Could not build wheels for thinc, which is required to install pyproject.toml-based projects
  [end of output]

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

× pip subprocess to install build dependencies 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.

and i got another error when trying " streamlit run mg.py".

ModuleNotFoundError: No module named ‘audiocraft’
Traceback:

File “/home/bayramserefoglu/.local/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 535, in _run_script
exec(code, module.dict)
File “/home/bayramserefoglu/MusicGeneration/mg.py”, line 6, in
from audiocraft.models import MusicGen

Installing audiocraft module and another error:

        thinc/backends/numpy_ops.cpp:1001:43: bilgi: in definition of macro 'unlikely'
         1001 |   #define unlikely(x) __builtin_expect(!!(x), 0)
              |                                           ^
        thinc/backends/numpy_ops.cpp:53763:16: bilgi: in expansion of macro '__Pyx_IsTracing'
        53763 |         return __Pyx_IsTracing(tstate, 0, 0) && retval;
              |                ^~~~~~~~~~~~~~~
        error: command '/usr/bin/gcc' failed with exit code 1
        [end of output]
  
    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for thinc
  Failed to build thinc
  ERROR: Could not build wheels for thinc, which is required to install pyproject.toml-based projects
  [end of output]

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

× pip subprocess to install build dependencies 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.

installed pyproject-toml but nothing change.

GitHub - vluz/MusicGeneration: Music Generation Using MusicGen and Audiocraft this is the script. Its creating music with AI.
If you know scripts for generating musics please tell me.

Thank you. Sorry for my bad english😊

Audiocraft requires Torch (and this project also uses Torch directly), so it is not supported on 3.12.

There are also special installation instructions for Audiocraft in the documentation. It requires a specific version of Torch, and expects you to install that first.

The project you found also has its own idea about how to install. It’s in the README on the page that you linked. Projects that use advanced tools like Torch aren’t always set up for Pip to work in the normal way.

This project is for helping make tools for other developers, so they can make their installers work properly. It cannot help you fix anything afterward.

TL;DR: You need Python 3.11

When asking help for some problem or error, it’s good to also briefly indicate:

  • What was the shell command you used? (Or did you try the install from inside an IDE like PyCharm?)
  • Were you running inside a Python virtual environment or not?
  • What is your OS? Which Python version are you using?

This is especially important for installation problems, since those can depend on any of those (OS, Python version, etc). (Some of the info can be extracted from the traceback, but even in that case it’s nice to get it upfront.)

In this case the two errors are identical and they are caused by a gcc build failure:

So, I assume you ran pip install audiocraft. This tries to install the thinc dependency. This then tries the build a wheel for thinc, which fails.

When I look at the thinc Pypi page and their project page, I see that it’s made by the makers of SpaCy (which gives me a lot of confidence that it’s solid code) and also that it claims to be compatible with Python 3.12 and that it provides installable wheels.

So, what is happening? Why is it trying to build a wheel instead of just downloading a wheel?
Because no suitable wheel is available for download. Why not? Afaik this kind of issue is usually caused by conflicts between versions of dependencies. The Python version can also be relevant (if a particular dependency is not yet compatible with your particular Python).

I think there are basically two different (non-exclusive) ways to proceed:

  • Tinker with the installation process (trial-and-error)
  • Try to better understand the actual root cause of the error

The error message in the wheel build is an indication of what failed. In this case (you didn’t show this) it’s probably this:

error: no member named 'use_tracing' in '_PyCFrame'

The main thing that is relevant here is that this indicates some version conflict. In this case, since _PyCFrame is something in the CPython code, you might guess there is an incompatibility with the Python version. But is it really thinc or some other package that is incompatible?[1]

At this point it’s good to look a bit closer at the dependencies of audiocraft. Version conflicts (and Python compatibility issues) are often caused by contraints on dependencies. In particular – pinning dependencies on exact versions, which may be an effort to close the gates of dependency hell, often has the reverse effect. I see that audiocraft is a repo from facebookresearch, but in the requirements.txt I notice it pins the torch version to 2.1.0 (and it has a warning that torch should be pre-installed) :confused:

Anyway, this suggests a way to either dig further or to start tinkering:

Set up a new Python virtual env for Python 3.12 and try to install, in order:

  • numpy
  • thinc
  • pytorch==2.1.0
  • audiocraft

You’ll then see that torch 2.1.0 will not install in Python 3.12. So, that’s the real problem here.
To use audiocraft you have to go back to Python 3.11.


  1. Spoiler: it’s not thinc and also not numpy ↩︎

2 Likes