修复subprocess.py文件错误:找不到文件?

时间:2019-04-09 19:20:26

标签: python

我正在使用Gray Arrow's Dejavu中的python软件包。我已经安装了运行我的代码所需的所有必需的依赖项和其他软件包。运行以下代码时:

    import warnings
    import json
    warnings.filterwarnings("ignore")

    from dejavu import Dejavu
    from dejavu.recognize import FileRecognizer

    with open('dejavu.cnf') as f:
        config = json.load(f)

    djv = Dejavu(config)

    djv.fingerprint_file('mp3/Sean-Fournier--Falling-For-You.mp3')

    song = djv.recognize(FileRecognizer, 'mp3/Sean-Fournier--Falling-For- 
    You.mp3')

    print("from file recognized: {}\n".format(song))

我收到以下错误:

    Traceback (most recent call last):
      File "testing.py", line 13, in <module>
        djv.fingerprint_file('mp3/Sean-Fournier--Falling-For-You.mp3')

      File "D:\dejavu-master\dejavu\__init__.py", line 109, in 
    fingerprint_file song_name=song_name

      File "D:\dejavu-master\dejavu\__init__.py", line 182, in 
    _fingerprint_worker channels, Fs, file_hash = decoder.read(filename, 
    limit)

      File "D:\dejavu-master\dejavu\decoder.py", line 51, in read
        audiofile = AudioSegment.from_file(filename)

      File "C:\Program Files\Python37\lib\site- 
    packages\pydub\audio_segment.py", line 665, in from_file info = 
    mediainfo_json(orig_file)

      File "C:\Program Files\Python37\lib\site-packages\pydub\utils.py", 
    line 263, in mediainfo_json res = Popen(command, 
    stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)

      File "C:\Program Files\Python37\lib\subprocess.py", line 775, in 
    __init__ restore_signals, start_new_session)

      File "C:\Program Files\Python37\lib\subprocess.py", line 1178, in 
    _execute_child startupinfo)

    FileNotFoundError: [WinError 2] The system cannot find the file 
    specified

我已经完成python 3.7以及所有软件包和依赖项的完全重新安装,以尝试更正此问题。

我不明白找不到哪个文件,并且已经进行了研究,希望找到解决该问题的方法。我非常感谢您可以与我分享有关此主题的任何帮助和知识。

1 个答案:

答案 0 :(得分:0)

尝试将“ Sean-Fournier--Falling-For-You.mp3”文件放置在脚本所在的确切目录中,我认为对mp3文件夹的文件夹引用没有得到正确处理:)

djv.fingerprint_file('mp3/Sean-Fournier--Falling-For-You.mp3')

song = djv.recognize(FileRecognizer, 'mp3/Sean-Fournier--Falling-For- 
You.mp3')