I am trying to upload an MP3 file and play it using pydub:
import pydub
from pydub import AudioSegment
from pydub.playback import play
blast_file = AudioSegment.from_mp3(
"C:/Users/am650/Downloads/radio_static.mp3")
From this, I get the following error:
C:\Users\am650\PycharmProjects\pythonProject\venv\Scripts\python.exe C:\Users\am650\PycharmProjects\pythonProject\crtt_control.py
C:\Users\am650\PycharmProjects\pythonProject\venv\Lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Users\am650\PycharmProjects\pythonProject\venv\Lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "C:\Users\am650\PycharmProjects\pythonProject\crtt_control.py", line 38, in <module>
blast_file = AudioSegment.from_mp3(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\am650\PycharmProjects\pythonProject\venv\Lib\site-packages\pydub\audio_segment.py", line 796, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\am650\PycharmProjects\pythonProject\venv\Lib\site-packages\pydub\audio_segment.py", line 728, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\am650\PycharmProjects\pythonProject\venv\Lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\am650\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1024, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\am650\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1493, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
Process finished with exit code 1
I have messed around with forward and back slashes, I tried putting r in front of the file call (r"C:/Users/am650/Downloads/radio_static.mp3")
, I have moved the file to different locations, etc. I have also tried other files and file types. It seems that python cannot find any file of mine...
I originally wrote this code on a mac (where it worked fine) and moved it to a PC. This error is occurring on the PC (windows 10). I am using Python 3.11.1 and I only have one version of Python downloaded. I had a similar problem earlier where Python would not recognise any of my pip installs, but I got around this by adding the packages directly in pycharm using PyPl. I now wounder if these two issues are related?
It is also worth noting that I am using a school computer that was configured such that all downloads automatically save to one drive, not the local computer. I have moved python (and the audio file) to the computer drive but maybe I have missed a file somewhere? I do not have another PC on which I can test these theories, and my IT department took a look and could not figure it out.