TeamPyOgg / PyOgg

Simple OGG Vorbis, Opus and FLAC bindings for Python
The Unlicense
64 stars 27 forks source link

import error on python3.7 #14

Closed C-gotoh closed 5 years ago

C-gotoh commented 5 years ago

I cannot import the current version of PyOgg==0.6.5a1:

Python 3.7.2 (default, Jan 10 2019, 23:51:51) 
[GCC 8.2.1 20181127] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyogg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/pyogg/__init__.py", line 8, in <module>
    from . import opus
  File "/usr/lib/python3.7/site-packages/pyogg/opus.py", line 724, in <module>
    libopusfile.opus_head_parse.restype = c_int
  File "/usr/lib/python3.7/ctypes/__init__.py", line 369, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.7/ctypes/__init__.py", line 374, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: opus_head_parse
Zuzu-Typ commented 5 years ago

This issue seems to be caused by the library pyogg is trying to load. Either the "opusfile" library was built without some specific symbols or a non related library is used by accident.

I'll commit a small change to the LibraryLoader code that will test wether or not the library is compatible. You should be able to import it afterwards, but you might not be able to certain files (such as .opus) without the respective libraries (opus and opusfile)

Zuzu-Typ commented 5 years ago

Please let me know if the issue persists.

C-gotoh commented 5 years ago

I can confirm that your commit fixed the symptom of this issue. The issue was that I did not have the opusfile library installed, but shouldn't this be an optional dependency as it is only relevant for decoding opus files? Either way, it appears that you made it optional with your fix, so I guess this is solved.

Zuzu-Typ commented 5 years ago

It was always optional, but my LibraryLoader found a library that it interpreted as the opusfile library, but it was actually some other library - it now checks the compatibility of the library candidate before using it.

Thank you very much for finding this bug!