0

I am trying to call this command: avconv -i '/opt/music/Smooth Criminal.mp3' -ac 1 -ar 22050 -b 352k -f wav - | /opt/pifm/bin/pifm - 98.3 with my own paths. In the terminal it works like a charm but when I run it through the python subprocess module I get this error:

Traceback (most recent call last): File "alarmclock.py", line 23, in <module> play_files(); File "alarmclock.py", line 9, in play_files call(["sudo avconv -i '/home/pi/Files/alarm.mp3' -ac 1 -ar 22050 -b 352k -f wav - | sudo '/home/pi/Files/pifm' - 105.9"]) File "/usr/lib/python2.7/subprocess.py", line 493, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.7/subprocess.py", line 679, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

I am sure the paths I have a real files and I know that because it works perfectly from terminal. For some reason the call method is not liking this line. I tried all sorts of combinations of quotes to make it know which were the paths, etc but I have not been able to get it to work.

From Python I am calling it like this: call(["$"]) where $ is the above command. If I change those quotes to single quotes it gives a syntax error: File "alarmclock.py", line 9 call(['avconv -i '/home/pi/Files/alarm.mp3' -ac 1 -ar 22050 -b 352k -f wav - | sudo /home/pi/Files/pifm - 89.9']) ^ SyntaxError: invalid syntax I cannot see anything wrong with the syntax there. Any ideas?

UPDATE: I tried suggestion in comments bellow to to switch both but that gave the same error. Any Ideas?

  • Try swapping the single and double quotes- you can just change one. So in your original version of the command, it should start 'avconf ... "/home/pi/Fil.... Make sense? – ifermon Aug 19 '15 at 22:32
  • I meant can't not can. Try swapping the single and double quotes- you can't just change one. So in your original version of the command, it should start 'avconf ... "/home/pi/Fil.... Make sense? – ifermon Aug 19 '15 at 22:38
  • That gives the same error. :-( Any other suggestions? – NULL Aug 19 '15 at 22:52
  • Which same error? invalid syntax or no such file or directory? – ifermon Aug 19 '15 at 23:06
  • Sorry, the no such file or directory error. – NULL Aug 19 '15 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.