fix: Error: python3 -c "import soundcard" #191#192
Conversation
|
What operating system and Python version are you trying to fix? Works fine on macOS 26 using Python 3.14. |
Hello python - 3.13.13 I removed the patch, built the RPM package without it, and tested it. The result is below. ~ ❯ python3 -c "import soundcard"
Traceback (most recent call last):
File "<string>", line 1, in <module>
import soundcard
File "/usr/lib/python3/site-packages/soundcard/__init__.py", line 4, in <module>
from soundcard.pulseaudio import *
File "/usr/lib/python3/site-packages/soundcard/pulseaudio.py", line 290, in <module>
_pulse = _PulseAudio()
File "/usr/lib/python3/site-packages/soundcard/pulseaudio.py", line 95, in __init__
self.context = _pa.pa_context_new(self.mainloop_api, self._infer_program_name().encode())
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3/site-packages/soundcard/pulseaudio.py", line 114, in _infer_program_name
return sys.argv[1][:30] + "..."
~~~~~~~~^^^
IndexError: list index out of range
~ ❯ rpm -qa | grep soundcard
python3-module-soundcard-0.4.6-alt2.noarch |
On Ubuntu, I needed to do: |
OS: ALT Regular x86_64
Thanks, but in my case this does not solve the problem mentioned above. Perhaps when the maintainer python3 at ALT updates Python to version 3.14 the problem will be solved, but for now it exists. |
|
What does this print? I doubt that upgrading Py3.13 to Py3.14 will fix anything. |
|
You seem to be running into a bug in |
I didn't have Pulseaudio installed. I installed it and launched it, but it didn't solve the problem. |
|
Cool! Now add: |
Personally, I worked around the error like this: return sys.argv[0][:30] + "..." I don't understand where the value of sys.argv[1] should come from if it's not there. sys.argv[0] = -c len(sys.argv) = 1 print(*sys.argv) = -c Where does sys.argv[1] come from? Or am I missing something? |
|
|
Awesome! Now do: |
|
This works on Ubuntu without modifying sudo apt update && sudo apt install --yes pulseaudio # or the equivelent on your Linux
pulseaudio --version # optional but a good sanity check
pulseaudio --start
pacmd load-module module-null-sink channels=6 rate=48000
pactl info # optional but a good sanity check
python3 -c "import soundcard" |
|
To be honest, I don’t even know what to answer you. |
|
The module itself works fine. I haven't had any problems with it other than this one. |


No description provided.