Skip to content
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

OSError: Could not read file name.flac #103

Open
donlombardo opened this issue May 5, 2022 · 9 comments
Open

OSError: Could not read file name.flac #103

donlombardo opened this issue May 5, 2022 · 9 comments

Comments

@donlombardo
Copy link

donlombardo commented May 5, 2022

On the latest Linux Mint xfce, converting 24/44100 wav extracted with Reaper to flac with SoundConverter, I get this error when trying o read it.

Traceback (most recent call last):
File "retageq.py", line 38, in
tagged = taglib.File("name.flac")
File "src/taglib.pyx", line 87, in taglib.File.cinit
OSError: Could not read file name.flac

It used to work in Xubuntu.

Install:

pip3 install pytaglib
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pytaglib in /home/andre/.local/lib/python3.8/site-packages (1.5.0)

libtag1-dev is already the newest version (1.11.1+dfsg.1-0.3ubuntu2).

What can I do?

@supermihi
Copy link
Owner

Did you check the file's permissions? (ls -l name.flac)?

@donlombardo
Copy link
Author

donlombardo commented Jun 1, 2022 via email

@supermihi
Copy link
Owner

Hi @donlombardo,
no, that looks absolutely okay. To be honest, I have no idea what's going on – are other tagging tools able to read the file?

@donlombardo
Copy link
Author

I'm sorry for my very late reply. Tes, Puddletag for example reads it just fine.
Flac test.zip

I've put together a small example that doesn't work for me. Output is:
Traceback (most recent call last): File "tag.py", line 2, in <module> foo = taglib.File("Test.flac") File "src/taglib.pyx", line 87, in taglib.File.__cinit__ OSError: Could not read file Test.flac

@supermihi
Copy link
Owner

Hi @donlombardo,
thanks for uploading the file. I have tested this on my machine, where it "unfortunaely" works without problem (the tags are empty, but no error is raised).
It could be something specific to the version of Linux Mint you are runnig – will try to find a Mint computer to verify that.

@donlombardo
Copy link
Author

Thank you for trying! It worked flawlessly on Ubuntu, so I guess you're right :)

@cheloveg
Copy link

cheloveg commented Apr 12, 2023

Having a same problem with .webm audio downloaded from yt-dlp, but everything works with a .m4a downloaded from a same video. I'm using Arch Linux with Python 3.10.9, pytaglib 2.0.0 and taglib 1.13-1.
Commands that i'm using to download audio are:

yt-dlp -f 251 "https://www.youtube.com/watch?v=fWNaR-rxAic"
yt-dlp -f 140 "https://www.youtube.com/watch?v=fWNaR-rxAic"

@mglukhovsky
Copy link

mglukhovsky commented Jul 9, 2024

@supermihi: I can reliably reproduce this error - I'm running a Python script on a large set of FLAC files to analyze them. I'm using the 3.0.0 release of pytaglib on macOS using Python 3.12.4, and scanning files on an external drive formatted as an exFAT volume.

What's odd is that:

  • If I start up a Python REPL in a separate shell instance, I can load the file with pytaglib perfectly fine and read the tags.
  • Permissions of the failed file are -rwx------ which are the same as every other file which succeeds.
  • Each run of the script produces a different subset of tracks which will fail this way - a different set (e.g. 5-10 out of 800 or so) will fail on each run. I have had a few runs where every track succeeds.
for i, filename in track_filenames:
  with taglib.File(filename) as track_taglib:
    tracks.append({
      'filename': filename,
      'tags': track_taglib.tags
    })

Example output:

*** OSError: Could not read file /Volumes/Ocean/Lossless/Art of Life/Headek EP/03 - Forgive.flac

It looks like this line in taglib.pyx is running a few checks, and I'm wondering what the output of self.cFile.file().isValid() might be. I tried to recompile the module myself via your open PR to also update TagLib to 2.0.1 (in case that fixes the issue) and to try to add some logging statements:

$ brew install cmake
$ python build_native_taglib.py
$ pip install --upgrade python
$ pip install --upgrade build

... but the last step fails:

...
      running build_ext
      building 'taglib' extension
      clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/Volumes/Ocean/bin/crates/pytaglib/lib/taglib-cpp/include -I/Volumes/Ocean/bin/crates/.venv/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/taglib.cpp -o build/temp.macosx-14.0-arm64-cpython-312/src/taglib.o -std=c++17
      src/taglib.cpp:9591:13: warning: code will never be executed [-Wunreachable-code]
                  goto bad;
                  ^~~~~~~~
      1 warning generated.
      clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk build/temp.macosx-14.0-arm64-cpython-312/src/taglib.o -L/Volumes/Ocean/bin/crates/pytaglib/lib/taglib-cpp/lib -L/Volumes/Ocean/bin/crates/pytaglib/lib/taglib-cpp/lib64 -ltag -o build/lib.macosx-14.0-arm64-cpython-312/taglib.cpython-312-darwin.so -std=c++17
      ld: warning: search path '/Volumes/Ocean/bin/crates/pytaglib/lib/taglib-cpp/lib64' not found
      installing to build/bdist.macosx-14.0-arm64/wheel
      running install
      running install_lib
      copying build/lib.macosx-14.0-arm64-cpython-312/pyprinttags.py -> build/bdist.macosx-14.0-arm64/wheel
      copying build/lib.macosx-14.0-arm64-cpython-312/taglib.cpython-312-darwin.so -> build/bdist.macosx-14.0-arm64/wheel
      running install_egg_info
      removing 'build/bdist.macosx-14.0-arm64/wheel/pytaglib-3.0.0-py3.12.egg-info' (and everything under it)
      Copying src/pytaglib.egg-info to build/bdist.macosx-14.0-arm64/wheel/pytaglib-3.0.0-py3.12.egg-info
      running install_scripts
      error: [Errno 2] No such file or directory: 'build/bdist.macosx-14.0-arm64/wheel/pytaglib-3.0.0-py3.12.egg-info'

What's odd is that the directory does seem to exist: /Volumes/Ocean/bin/crates/pytaglib/build/bdist.macosx-14.0-arm64/wheel/pytaglib-3.0.0-py3.12.egg-info

Are there any other debugging steps you recommend?

@mglukhovsky
Copy link

I decided to try the same codebase and FLAC library on Debian Linux 12.6 (bookworm) using the same version of pytaglib—TagLib was able to read all files without a hitch. This indicates it's something unique to either reading off the ExFAT filesystem, or the macOS implementation of TagLib. (Just surmising here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants