microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
16.95k stars 799 forks source link

portaudio.h: No such file or directory #9896

Open EdSeymore opened 1 year ago

EdSeymore commented 1 year ago

Windows Version

Microsoft Windows [Version 10.0.22621.1413]

WSL Version

WSL version: 1.1.3.0

Are you using WSL 1 or WSL 2?

Kernel Version

Linux version 5.15.90.1-microsoft-standard-WSL2

Distro Version

Release: 22.04

Other Software

miniconda conda 23.3.1 pip3 pip 23.0.1 PyAudio

Repro Steps

pip3 install PyAudio

Expected Behavior

normal PyAudio install as under native Ubuntu 22.04

Actual Behavior

fatal error: portaudio.h: No such file or directory

Diagnostic Logs

No response

Biswa96 commented 1 year ago

The issue is not related to WSL. Please report any on-topic issues.

The portaudio.h file is provided by portaudio19-dev package. The file list of that package can be found here https://packages.ubuntu.com/jammy/amd64/portaudio19-dev/filelist.

EdSeymore commented 1 year ago

It is my understanding that portaudio is provied by standard Ubuntu package and that WSL supplies a non standerd Ubuntu for the WSL support. The files referenced are not present in my Ubuntu 22.04 image under WSL2 with Windows 11.

Biswa96 commented 1 year ago

The portaudio19-dev has to be installed to get that portaudio.h file.

elsaco commented 1 year ago

@EdSeymore you need to add the portaudio19-dev package. This package contains the development files and not installed by default. apt install portaudio19-dev should take care of it.

EdSeymore commented 1 year ago

Thanks. Now Successfully installed PyAudio-0.2.13.

EdSeymore commented 1 year ago

Now I am getting a stream of messages from ALSA lib:

ALSA lib confmisc.c:855:(parse_card) cannot find card '0' ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib confmisc.c:855:(parse_card) cannot find card '0' ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory and many more:

This may not be an WSL2 problem; but, I am trying really hard to use WSL2 with Ubuntu in place of a separate Ubuntu system and the complexity of the Operating Systems is making this really difficult.

End users should not have this much trouble setting up a working environment to run python applications. Trying to debug configuration problems with web search has not been productive for me.

I really have no idea how Windows and Ubuntu share devices on a single system and very little desire to know. I just would like for supportted systems to actually work when installed.

WSL2 just happens to be a key component.

Has anyone gotten PyAudio to work on Ubuntu 22.04 with Windows 11 and WSL2 without the ALSA lib messages?

Suggestions would be appreciated.

EdSeymore commented 1 year ago

Ref: https://stackoverflow.com/questions/71945812/audio-recording-script-not-working-on-wsl2-ubuntu

EdSeymore commented 1 year ago

The python3 code to illistrate this conditions is as follows:

!/usr/bin/env python3

-- coding: utf-8 --

import pyaudio import wave import sys CHUNK = 1024 file_path = "audio.wav" wf = wave.open(file_path, 'rb') # Modified ets 01/31/2023 t_audio =wf.getnframes() / wf.getframerate() p = pyaudio.PyAudio() stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) while len(data := wf.readframes(CHUNK)): stream.write(data) stream.close() p.terminate() wf.close()

gml16 commented 11 months ago

I am having the same issue. Has there been any update regarding this please?

Jeronymous commented 3 months ago

At the time being, has anyone succeeded to have pyaudio working in WSL2?

pranav-manik commented 3 months ago

^^