Skip to content

BUG: vocalpy won't work in jupyter notebook run in vscode after ipykernel install #193

Open

Description

@eintzandt

I installed vocalpy using:
conda create -n vocalpy python=3.11
conda activate vocalpy
conda install vocalpy -c conda-forge

Then I opened a new jupyter notebook in VScode and couldn't start the kernel in vocalpy because I didn't have ipykernel installed, so I installed ipykernel using:
conda install -n vocalpy ipykernel --update-deps --force-reinstall

Now I get this error when importing vocalpy into my jupyter notebook:
image

Is there a different ipykernel installation I should try that might not give me this error?

Desktop operating System: Windows 10

Activity

  1. self-assigned this
    on Oct 21, 2024
  2. NickleDave commented on Oct 21, 2024

    @NickleDave
    Contributor

    Hi @eintzandt sorry you're running into this issue, I'm happy to help.
    Thank you for providing a detailed report of the problem.

    My best guess is that you are right that some interaction of ipykernel and anaconda is the source of the problem, but I'm not sure why. (Edit: I don't usually run Jupyter notebooks in vs code so bear with me)

    Can you please do the following for me?

    • run the following in the terminal, inside your activated vocalpy env: conda env export > environment.yml
    • then run conda list --explicit > spec-file.txt
    • reply to this with both of those files in a zip attachment (since GitHub won't let you reply with txt + yml files as attachments)

    If you use Powershell, I am not sure those commands will work, so you may need to use Anaconda Prompt, that runs Windows terminal. They will help us see what's in the environment (I'm trying to figure out if maybe --update-deps installed a different version of pysoundfile or something.)

    You could also try a couple of other things to confirm the problem is from conda + ipykernel interactions:

    • Make a Python virtualenv (without conda) and install both vocalpy and jupyterlab into that environment, and see if you can get that to run
    • make a conda env in the terminal with vocalpy + jupyterlab and then launch from the terminal, and see if it works then

    If both of those "control experiments" work, then we know it's definitely something weird that happened from the ipykernel installation

    If you're not sure how to do either of those last two things, let me know, and I can give you more step-by-step instructions

  3. eintzandt commented on Oct 21, 2024

    @eintzandt
    Author

    vocalpy_zip.zip
    Here are the zipped files, I will test out your 2 suggestions now. Thank you!

  4. NickleDave commented on Oct 21, 2024

    @NickleDave
    Contributor

    Thank you @eintzandt for the quick reply.
    From those, it looks to me like both pysoundfile and the libsndfile that it uses are in fact the conda-forge versions -- so it's not because something else got installed.

    One more question:

    • did you try restarting VS code?

    I can test locally on a Windows machine to see if I can reproduce the bug.
    It's not obvious to me what the fix would be so you can run in VS code.
    You could maybe try conda uninstall pysoundfile followed by pip install soundfile so you are using the pure Python version that has its "own" versions of libsndfile built in?
    Although IIUC in general we want to avoid using pip after conda when we care about reproducibility (just a heads up, apologies if you know this already).

    Might also be worth trying to conda install ipykernel without the --update-deps --force-reinstall to see if that is the source of the problem.

    If that fails, you might need to run Jupyter outside VS Code to use vocalpy. I want vocalpy to work for you in whatever way is convenient, though, happy to keep working with you to see if we can figure this out

  5. eintzandt commented on Oct 21, 2024

    @eintzandt
    Author

    Okay I got it to work by doing the following:
    conda uninstall pysoundfile
    pip install soundfile
    (this caused vocalpy to uninstall, so then I did)
    conda install vocalpy -c conda-forge

    I think the conda version of pysoundfile must have caused some issues with Jupyter notebook in VS code. I've attached the zipped files again so you can see what versions of the packages ended up working. Thank you for your help!
    spec-file.zip

  6. changed the title [-]BUG: OSError: cannot load library 'libsndfile.dll': error 0x7e after installing ipykernel[/-] [+]BUG: vocalpy won't work in jupyter notebook run in vscode after ipykernel install[/+] on Oct 21, 2024
  7. NickleDave commented on Oct 21, 2024

    @NickleDave
    Contributor

    Great, thank you @eintzandt for letting me know that workaround got you going for now!

    I'll leave this and open and tweak the title a bit to remind me of the issue, will see if we can track down the source

  8. NickleDave commented on Oct 21, 2024

    @NickleDave
    Contributor

    Note to self that this looked possibly related: bastibe/python-soundfile#373

    Error is the same

    ~\anaconda3\lib\site-packages\soundfile.py in <module>
        190             _snd = _ffi.dlopen(_os.path.join(_hbrew_path, _explicit_libname))
        191         else:
    --> 192             _snd = _ffi.dlopen(_explicit_libname)
        193 
        194 __libsndfile_version__ = _ffi.string(_snd.sf_version_string()).decode('utf-8', 'replace')
    
    OSError: cannot load library 'libsndfile.dll': error 0x7e
    

    But in traceback above it's in .conda\envs\vocalpy\Library\bin so it's not some system-wide Anaconda thing

  9. NickleDave commented on Oct 25, 2025

    @NickleDave
    Contributor

    @all-contributors please add @eintzandt for bug and data

  10. allcontributors commented on Oct 25, 2025

    @allcontributors
    Contributor

    @NickleDave

    I've put up a pull request to add @eintzandt! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions