music player programming. ran into a problem. The program should play the file that I run using my program. For this, I formatted the code in exe. When I started using my exe an error occurred
Traceback (most recent call last):
File "MP3.py", line 13, in <module>
File "MP3.py", line 7, in music
pygame.error
[1980] Failed to execute script MP3
MP3.py -my python code/
import pygame
import sys
f = str(sys.argv[1])
print(f)
def music(f):
pygame.init()
clock = pygame.time.Clock()
pygame.mixer.music.load(f)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
pygame.mixer.init(22050,-16,2)
music(f)
various methods do not help.
although the code with music playback works shortly and in exe as well as the output of the file that I launch by the program
this error
C:\Users\Acer\Documents\Projects\MP3\Test.mp3
Traceback (most recent call last):
File "MP3.py", line 15, in <module>
music(f)
File "MP3.py", line 9, in music
pygame.mixer.music.load(f)
pygame.error
[17280] Failed to execute script MP3
You should first use pygame.mixer.init before using mixer to do anything you want. You can refer to this document for details about how to tweak the parameters of the mixer.
Related
When I call the function get_monitors()
from screeninfo import get_monitors
monitors = get_monitors()
I keep getting this error:
Traceback (most recent call last):
File "C:/Users/User/manim/test1/functionTest.py", line 3, in <module>
monitors = get_monitors()
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\screeninfo\screeninfo.py", line 37, in get_monitors
raise ScreenInfoError("No enumerators available")
screeninfo.common.ScreenInfoError: No enumerators available
I've tried deleting ScreenInfo and reinstalling it, and installing some other
packages such as pynput to no success.
Maybe me using the kivy library did something?
error:
Traceback (most recent call last):
File "src\\gevent\\greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
File "eel\__init__.py", line 259, in _process_message
File "main.py", line 40, in play_music
pygame.error: Failed loading libmpg123-0.dll: The specified module could not be found.
2020-08-28T18:46:27Z <Greenlet at 0x4b29138: _process_message({'call': 1.305899873486772, 'name': 'play_music', , <geventwebsocket.websocket.WebSocket object at 0x0)> failed with error
pyinstaller command:
python -m eel main.py web --console --onefile --icon=ico.ico
mp3 files don't play but wav files works...
Try the following snippet:
import pygame
mp3_file = 'song.mp3'
pygame.init()
pygame.mixer.init()
clock = pygame.time.Clock()
pygame.mixer.music.load(mp3_file)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
clock.tick(10)
This should play the music and run the rest of the game.
You are able to do the following as well:
import pygame
mp3_file = 'song.mp3'
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(mp3_file)
pygame.mixer.music.play()
pygame.event.wait()
But the game will stop executing and wait for the mp3 to finish. This is because of pygame.event.wait()
There are many examples here: Play MP3 in pygame
There is a link to an mp3 file that needs to be streamed from a URL like http://example.com/music_radio.mp3 and played on a computer. On the Internet, although there are examples of streaming audio, but they are mainly for Python2, and for Python3 there are no such libraries anymore, I tried to do it this way:
import vlc
p = vlc.MediaPlayer ("http://example.com/music_radio.mp3")
p.play ()
But it constantly displays an error:
Traceback (most recent call last): File "PythonProjects / URL /
main.py", line 2, in import vlc File "PythonProjects / URL / venv /
lib / python3.6 / site-packages / vlc / init.py", line 3, in public
import ModuleNotFoundError: No module named 'public'
And the problem is that the public module is not installed. How can you solve this problem or how else can you receive and play audio by reference?
UPD: That link suggests either non-working code, or code using Python2, not Python3
UPD2: When using python-vlc, this error occurs:
Traceback (most recent call last): File
"PythonProjects/URL/main.py", line 4, in
import vlc File "PythonProjects/URL/venv/lib/python3.6/site-packages/vlc.py",
line 203, in
dll, plugin_path = find_lib() File "PythonProjects/URL/venv/lib/python3.6/site-packages/vlc.py",
line 194, in find_lib
ctypes.CDLL('libvlccore.dylib') File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/init.py",
line 348, in init
self._handle = _dlopen(self._name, mode) OSError: dlopen(libvlccore.dylib, 6): image not found
If this can help
from IPython.display import Audio
Audio(url="http://www.nch.com.au/acm/8k16bitpcm.wav")
I am running Python 2.7 on Mac OS X. I have downloaded and installed pydc1394 so as to have it as a python library. I'm trying to run the save_image.py program. The camera is connected via USB to my Mac. When I try to run the code, however, I get an error saying
Opening camera!
Traceback (most recent call last):
File "<string>", line 100, in <module>
File "build/bdist.macosx-10.6-intel/egg/pydc1394/camera2.py", line 1009, in __init__
IndexError: list index out of range
[Finished in 0.1s]
The code for pydc1394 can be found in https://github.com/jordens/pydc1394.
My guess is that it doesn't sense the camera, however I am sure that it is 1394 compatible, and that it is connected to the laptop.
Thank you!
I've just installed PyBluez on my windows 8 laptop, and I've tried to launch the module examples to test if it works properly.
When I run the examples/simple/inquiry.py file I get the following error:
C:\Users\Manuel\AppData\Local\Programs\Python\Python35-32\Lib\site-packages>python C:\Users\Manuel\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\PyBluez-0.22\examples\simple\inquiry.py
performing inquiry...
Traceback (most recent call last):
File "C:\Users\Manuel\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\PyBluez-0.22\examples\simple\inquiry.py", line 13, in <module>
duration=8, lookup_names=True, flush_cache=True, lookup_class=False)
File " C:\Users\Manuel\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\bluetooth\msbt.py", line 15, in discover_devices
devices = bt.discover_devices(duration=duration, flush_cache=flush_cache)
OS Error
My bluetooth is turned on, and I have no idea of what's going on.
Any help?