파이썬에서 간단히 오디오 파일을 재생해야 하는 경우 playsound 라이브러리를 활용할 수 있습니다. 사용법은 이전 글을 참고해주세요. - [python] playsound 모듈로 음악 재생하기 그런데 최근에 이 라이브러리(버전 1.3.0)를 설치해서 테스트해봤는데 오디오 파일 재생이 안 되면서 다음과 같은 에러가 발생했습니다.
이 에러 해결을 위해서 제가 취한 것은 버전을 1.2.2로 내린 것(downgrade)입니다.
그랬더니 해당 예외가 발생하지 않고 음악이 재생되었습니다. I'm trying to play a sound with the python library I saw other questions on Stack Overflow, but I haven't found a valid solution for my problem. Here is the piece of code that should play the sound:
This is the error:
I've also tried uninstalling Does anyone have a solution?🤔
Andrea M 2,2041 gold badge8 silver badges26 bronze badges asked Aug 5 at 16:26
It's probably a file system issue. When the code runs in the playsound module, it doesn't recognize the relative path you entered. Instead, you need to enter an absolute path. Try:
Alternatively:
answered Aug 6 at 9:39
OmriOmri 4133 silver badges12 bronze badges 1 I had already used playsound in several projects to run audio files. When I tried to run one of my old projects it resulted in an error, I figured out that it is caused by playsound. Even a simple code results in an error, can anyone tell me how to run the audio files with playsound? any help is appreciable :) note: punch.mp3 is located in the same directory and am currently using python 3.9 code:
output: Error 275 for command: open PUNCH.mp3 Cannot find the specified file. Make sure the path and filename are correct. Error 263 for command: close PUNCH.mp3 The specified device is not open or is not recognized by MCI. Failed to close the file: PUNCH.mp3 Traceback (most recent call last): File "d:\programming\Python\test.py", line 3, in <module> playsound("PUNCH.mp3") File "C:\Users\Erlik\AppData\Local\Programs\Python\Python39\lib\site-packages\playsound.py", line 72, in _playsoundWin winCommand(u'open {}'.format(sound)) File "C:\Users\Erlik\AppData\Local\Programs\Python\Python39\lib\site-packages\playsound.py", line 64, in winCommand raise PlaysoundException(exceptionMessage) playsound.PlaysoundException: Error 275 for command: open PUNCH.mp3 Cannot find the specified file. Make sure the path and filename are correct. Output: modulenotfounderror:no module named 'gi' Yup you need to install module gi or maybe the name is wrong It is playsound not Playsound also for gi ,the actual module name is pgi or gi ,I really can't tell even after researching a lot about it on Google You could search for the required library depending on the platform you're using if you don't have them and it wouldn't be that hard You can use thinkdsp library and make_audio function for make a sound.... When I pip install gi it says could not find a version that satisfies the requirement gi (from versions:) no matching distribution found for gi And when I tried to import playsound with the p as a capital letter I got an error that said modulenotfounderror:no module named 'Playsound' Could it be happening because I'm using android? Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 3, in <module> File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.7/site-packages/playsound.py", line 91, in _playsoundNix import gi ModuleNotFoundError: No module named 'gi' [Program finished] /storage/emulated/0 $ pip install gi Collecting gi Could not find a version that satisfies the requirement gi (from versions: ) No matching distribution found for gi /storage/emulated/0 $ Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'Playsound' [Program finished] Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 3, in <module> NameError: name 'Playsound' is not defined [Program finished] Nicolas okiokpa if you have solved then please tell again the whole process how you have solved in Android |