-
Notifications
You must be signed in to change notification settings - Fork 151
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
MacOS : Cannot allocate write+execute memory for ffi.callback() #397
Comments
See #270. I'm open to suggestions how to improve the situation. |
I cloned the repo and hacked at it until it worked. https://github.com/gormster/python-sounddevice/tree/api-mode-experimental Note that this replaces ABI mode completely with API mode. I'm sure there's a graceful way to handle both. also, I should probably be overriding |
Thanks @gormster, see also #91.
This would be great, but I'm not so sure that's possible. See also https://groups.google.com/g/python-cffi/c/oBMFw7R1sFI/m/LJDo6NPJCwAJ |
Ok so… I've done a thing where it does (I think) handle this gracefully. (Well, sort of; it uses an environment variable at runtime to select which mode to use. That was the best I could think of without breaking the API.) However, in testing it, I realised the original problem is actually only occurring when using a So I tried using it under my And here's the kicker: if I go into a fresh conda environment with numpy installed, then within that environment do In short: I have no real way of testing that this patch fixes this bug at all. Now, this all said, API mode is clearly superior in cases where a C compiler is available, or for which a wheel can be precompiled, and it sure seems like the way I've done it does switch between API and ABI mode seamlessly… but again, it's tough to test if that's actually what's happening. |
@ealpha In case you missed it in that wall of text, here's a potential workaround:
|
Not contributing to the actual issue, but if I install via conda Otherwise one would do So an okay way around that would be (resulting in a version of portaudio from conda-forge, but same version number as conda-main):
|
There are at least two versions of the PortAudio library availble for
It is theoretically possible to install However, it is possible to not install In any case, you can check which library is actually used like this: import sounddevice as sd
print(sd._libname) In general, I would recommend
This seems unfortunate. Why is https://anaconda.org/anaconda/numpy |
FYI, the difference is what accelerated linear algebra library Numpy is built against, as documented here |
This worked for me. Just a heads up for other people, if you conda install other packages that has cffi as a dependency (after |
I still have this problem in macOS 12.6 |
@ealpha You may want to make sure that you install cffi via pip as well as stated by @AjaniStewart. I can confirm that the workaround works on macOS 12.6 & arm64 if cffi and sounddevice are installed using pip. |
Hi, I had the same issue with my M1 mac mini, macos 13.0 & anaconda environment.
It works for me. |
python3 play_file.py file.wav
MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks
The text was updated successfully, but these errors were encountered: