1

I have a python program which inputs a .wav file name from the user, does some filtering and writes the output to another .wav file. The programs works perfectly well when I run it using the interpreter. But when I run the program using command prompt, it prompts for the input audio filename, but when I type the .wav filename and press enter, I get the following error:

Traceback (most recent call last):
File "C:\python_audio\stereo.py", line 15, in <module>
(fs, x) = read(audio_in,'rb')
File "C:\Python27\Lib\site-packages\scipy\io\wavfile.py", line 155, in read
fid = open(filename, 'rb')
IOError: [Errno 2] No such file or directory: 'chostakovitch.wav'

The python program stereo.py and the .wav file (chostakovitch.wav) are in the path C:\python_audio, and I have added this path as an environment variable.

But I can't figure out why I am still getting this error?

Pallavi
  • 119
  • 1
  • 2
  • 10
  • 1
    Define the paths correctly and it won't happen.. nothing more to be said here.. – Idos Jan 20 '16 at 12:17
  • see http://stackoverflow.com/questions/1668594/where-does-python-first-look-for-files – Muhammad Tahir Jan 20 '16 at 12:28
  • It looks like you're trying to open the file `chostakovitch.wav` instead of `C:\python_audio\chostakovitch.wav`. When you define the variable `filename` specify the full path. – toti08 Jan 20 '16 at 12:28
  • If you want to search `PATH` and the working directory for the file in Python 2, on Windows Vista and later you can use `filename = subprocess.check_output('where "%s"' % filename).splitlines()[0]`. If it's not found the statement raises a `subprocess.CalledProcessError` exception. – Eryk Sun Jan 20 '16 at 16:48

0 Answers0