Giter VIP home page Giter VIP logo

Comments (3)

mcclure avatar mcclure commented on July 20, 2024 1

Let me try again, I think I have a better repro.

Say I create a brand new fresh venv, and then I install python-soundfile. I then run this ultra-simple script:

import soundfile
soundfile.write("test.wav", [[0,0]], 48000)

This fails with "ModuleNotFoundError: No module named 'numpy'". (So does read().)

Looking in setup.py, I find that there is a "numpy" feature in extras_require, and that it does create a numpy dependency. But you only get this if you (?) install with pip install soundfile[numpy], and this is not documented either in the toplevel documentation or the documentation for the functions (such as read and write) which require numpy. (It is mentioned in the changelog that read and write require numpy but buffer_read and buffer_write do not, but this is not a very clear place for it.)

So my "expected behavior" would be one of the following changes:

  • Move numpy from an extras_require to a regular install require (if it helps, I got this working locally and submitted it as PR #409 ). If, as you say, nearly all users of python-soundfile use numpy already, then this change would be harmless.
  • If it is important to you to support the no-numpy buffer_read/buffer_write case, then more specifically document the existence of soundfile[numpy] and specifically note in the function documentation which functions require numpy. (A warning message, or addition to the exception's error string, like "install with soundfile[numpy] to fix this" when the ModuleNotFoundError is raised from read() and write(), would also be helpful, but not required.)

from python-soundfile.

bastibe avatar bastibe commented on July 20, 2024 1

I agree. Let's require numpy for the next version of soundfile. The entire point of the library is to expose a numpy interface to libsndfile.

from python-soundfile.

bastibe avatar bastibe commented on July 20, 2024

Soundfile can indeed be used without numpy, if you use the buffer_* functions.

These were perhaps a bad idea, as almost all people no doubt use soundfile with numpy. But backwards compatibility is a thing, so that's how it is.

from python-soundfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.