[GH-ISSUE #7] FileNotFoundError: [Errno 2] No such file or directory: 'rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json' when using UVR.uvr_wrapper() #7

Open
opened 2026-10-20 09:53:01 +00:00 by bsakaguchi · 3 comments
Owner

Originally created by @wAIfu-DEV on GitHub (Jan 27, 2024).
Original GitHub issue: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion/issues/7

Hi, getting this error when using the UVR.uvr_wrapper() function:

Loading UVR
Extracting vocals...
Traceback (most recent call last):
  File "C:\Users\jeje9\Desktop\rvc_test\rvc_test.py", line 27, in <module>
    for i in result:
  File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\modules\uvr5\modules.py", line 49, in uvr_wrapper
    pre_fun = func(
  File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\modules\uvr5\vr.py", line 31, in __init__
    mp = ModelParameters("rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json")
  File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\lib\uvr5_pack\lib_v5\model_param_init.py", line 55, in __init__
    with open(config_path, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json'

Here is my code:

import os

from dotenv import load_dotenv
from rvc.modules.uvr5.modules import UVR

# downloaded uvr model from:
# https://github.com/TRvlvr/model_repo/releases/

cwd = os.getcwd()
load_dotenv(".env")

print("Loading UVR")
uvr = UVR()

print("Extracting vocals...")

result = uvr.uvr_wrapper(
    model_name="2_HP-UVR.pth",
    audio_path=cwd + "audio.wav",
    save_vocal_path=cwd + "vocal.wav",
    save_ins_path=cwd + "inst.wav",
    agg=10, 
    export_format="wav",
    temp_path=cwd + "tmp.wav")

for i in result:
    print(i)

I made sure to look at the path, and the file does exist, so I'm thinking it might be an issue with the expected CWD since the path is relative.
For more info: I'm running python from a venv and using this command to run: ./Scripts/python.exe rvc_test.py from the C:\Users\jeje9\Desktop\rvc_test directory where the rvc_test.py file is

Originally created by @wAIfu-DEV on GitHub (Jan 27, 2024). Original GitHub issue: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion/issues/7 Hi, getting this error when using the UVR.uvr_wrapper() function: ``` Loading UVR Extracting vocals... Traceback (most recent call last): File "C:\Users\jeje9\Desktop\rvc_test\rvc_test.py", line 27, in <module> for i in result: File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\modules\uvr5\modules.py", line 49, in uvr_wrapper pre_fun = func( File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\modules\uvr5\vr.py", line 31, in __init__ mp = ModelParameters("rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json") File "C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\lib\uvr5_pack\lib_v5\model_param_init.py", line 55, in __init__ with open(config_path, "r") as f: FileNotFoundError: [Errno 2] No such file or directory: 'rvc/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json' ``` Here is my code: ```python import os from dotenv import load_dotenv from rvc.modules.uvr5.modules import UVR # downloaded uvr model from: # https://github.com/TRvlvr/model_repo/releases/ cwd = os.getcwd() load_dotenv(".env") print("Loading UVR") uvr = UVR() print("Extracting vocals...") result = uvr.uvr_wrapper( model_name="2_HP-UVR.pth", audio_path=cwd + "audio.wav", save_vocal_path=cwd + "vocal.wav", save_ins_path=cwd + "inst.wav", agg=10, export_format="wav", temp_path=cwd + "tmp.wav") for i in result: print(i) ``` I made sure to look at the path, and the file does exist, so I'm thinking it might be an issue with the expected CWD since the path is relative. For more info: I'm running python from a venv and using this command to run: `./Scripts/python.exe rvc_test.py` from the `C:\Users\jeje9\Desktop\rvc_test` directory where the `rvc_test.py` file is
Author
Owner

@wAIfu-DEV commented on GitHub (Jan 27, 2024):

This indeed seems to be the cause of the crash. I took the liberty to add a print statement in the source code, right before the call to open()
image
And got the path: C:\Users\jeje9\Desktop\rvc_test\rvc\lib\uvr5_pack\lib_v5\modelparams\4band_v2.json when the correct path should have been: C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\lib\uvr5_pack\lib_v5\modelparams\4band_v2.json

<!-- gh-comment-id:1913335325 --> @wAIfu-DEV commented on GitHub (Jan 27, 2024): This indeed seems to be the cause of the crash. I took the liberty to add a print statement in the source code, right before the call to `open()` ![image](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion/assets/132222556/891e9722-716d-438a-ab6f-83106bd91fe8) And got the path: `C:\Users\jeje9\Desktop\rvc_test\rvc\lib\uvr5_pack\lib_v5\modelparams\4band_v2.json` when the correct path should have been: `C:\Users\jeje9\Desktop\rvc_test\lib\site-packages\rvc\lib\uvr5_pack\lib_v5\modelparams\4band_v2.json`
Author
Owner

@wAIfu-DEV commented on GitHub (Jan 27, 2024):

Manually setting the CWD of the python script using os.chdir() fixes the issue on my end.

import os
import pydub

cwd = os.getcwd()
ffmpeg_exec = cwd + "\\ffmpeg.exe" # or any other path to ffmpeg, as long as it is absolute and not relative.

pydub.AudioSegment.converter = ffmpeg_exec

from dotenv import load_dotenv
from rvc.modules.uvr5.modules import UVR

# downloaded model from:
# https://github.com/TRvlvr/model_repo/releases/

load_dotenv(".env")

print(cwd)

print("Loading UVR")
uvr = UVR()

print("Extracting vocals...")

os.chdir(cwd + "\\Lib\\site-packages")

result = uvr.uvr_wrapper(
    model_name="2_HP-UVR.pth",
    audio_path=cwd + "\\audio.wav",
    save_vocal_path=cwd + "\\vocal",
    save_ins_path=cwd + "\\inst",
    agg=5,
    export_format="wav",
    temp_path=cwd + "\\tmp")

for i in result:
    print(i)
<!-- gh-comment-id:1913354110 --> @wAIfu-DEV commented on GitHub (Jan 27, 2024): Manually setting the CWD of the python script using `os.chdir()` fixes the issue on my end. ```python import os import pydub cwd = os.getcwd() ffmpeg_exec = cwd + "\\ffmpeg.exe" # or any other path to ffmpeg, as long as it is absolute and not relative. pydub.AudioSegment.converter = ffmpeg_exec from dotenv import load_dotenv from rvc.modules.uvr5.modules import UVR # downloaded model from: # https://github.com/TRvlvr/model_repo/releases/ load_dotenv(".env") print(cwd) print("Loading UVR") uvr = UVR() print("Extracting vocals...") os.chdir(cwd + "\\Lib\\site-packages") result = uvr.uvr_wrapper( model_name="2_HP-UVR.pth", audio_path=cwd + "\\audio.wav", save_vocal_path=cwd + "\\vocal", save_ins_path=cwd + "\\inst", agg=5, export_format="wav", temp_path=cwd + "\\tmp") for i in result: print(i) ```
Author
Owner

@Tps-F commented on GitHub (Feb 4, 2024):

Sorry it took me so long to notice.
I haven't tested it on windows yet, I'll fix it again.

<!-- gh-comment-id:1925618381 --> @Tps-F commented on GitHub (Feb 4, 2024): Sorry it took me so long to notice. I haven't tested it on windows yet, I'll fix it again.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
RVC-Project/Retrieval-based-Voice-Conversion#7
No description provided.