PyOgg icon indicating copy to clipboard operation
PyOgg copied to clipboard

NameError: name 'c_int_p' is not defined in pyogg library

Open santiarr opened this issue 1 year ago • 2 comments

I encountered a NameError when trying to use the pyogg library. The error message indicates that c_int_p is not defined. This issue occurs when attempting to use the OpusDecoder from the pyogg library.

OS: macOS (M1) Python version: 3.10.0 pyogg version: [Specify the version you are using] Additional Information: I have installed the necessary dependencies for libopus using Homebrew:

I have also set the DYLD_LIBRARY_PATH environment variable in my .env file:

ibopus.opus_encoder_create.argtypes = [opus_int32, c_int, c_int, c_int_p] NameError: name 'c_int_p' is not defined. Did you mean: 'c_int'?

santiarr avatar Oct 27 '24 07:10 santiarr

I ran into the same. no solution?

goodpeter-sun avatar Nov 08 '24 01:11 goodpeter-sun

I found a solution for MacOS M1/M2. The issue occurs because system libraries are located in a different path and opuslib cannot find them.

Solution Steps:

  1. First, install required libraries using Homebrew:
brew install libogg opus opusfile libopusenc libvorbis flac
brew install opus-tools
  1. On M1/M2 Macs, Homebrew libraries are located under /opt/homebrew/lib/. Verify the libraries exist:
ls /opt/homebrew/lib/libopus*
  1. Set system library paths. Add these lines to your ~/.zshrc (or your shell config file):
export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
export LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH
export PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH
  1. Apply the changes:
source ~/.zshrc
  1. Reinstall PyOgg or opuslib:
pip uninstall opuslib
pip install --no-cache-dir opuslib

After following these steps, the library should work correctly. This solution addresses the issue caused by Homebrew installing libraries under /opt/homebrew/lib/ on M1/M2 Macs.

ozanyurt avatar Jan 12 '25 12:01 ozanyurt