Skip to content

fix: add missing __init__.py to avoid ModuleNotFoundError on infer module #2543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

haru2503
Copy link

@haru2503 haru2503 commented Apr 9, 2025

Pull request checklist

  • The PR has a proper title. Use Semantic Commit Messages.

  • Make sure this is ready to be merged into the relevant branch.

  • Ensure you can run the code you submitted successfully.

PR Type:

  • Bug fix

Description

  • This pull request fixes a ModuleNotFoundError when running training/preprocessing scripts using python -m ....

  • The error occurs because Python does not recognize certain subdirectories as packages unless they contain an init.py file.

Example error:

(venv) PS D:\rvc\Retrieval-based-Voice-Conversion-WebUI> python infer/modules/train/preprocess.py ../wav 44100 2 ../processed_data False 0.1
Traceback (most recent call last):
  File "infer/modules/train/preprocess.py", line 23, in <module>
    from infer.lib.audio import load_audio
ModuleNotFoundError: No module named 'infer.lib'

Or when using python -m:

(venv) PS D:\rvc\Retrieval-based-Voice-Conversion-WebUI> python -m infer.modules.train.preprocess
Error while finding module specification for 'infer.modules.train.preprocess' (ModuleNotFoundError: No module named 'infer.modules')

📦 What it affects:

  • Adds the missing __init__.py files in the following directories:
infer/__init__.py
infer/lib/__init__.py
infer/modules/__init__.py
infer/modules/train/__init__.py
  • This resolves import issues for infer.modules.train.* and improves out-of-the-box compatibility — especially for Windows users, IDE users, and people running scripts via -m.

Screenshot

  • Not applicable

@haru2503 haru2503 force-pushed the fix-missing-init-py branch from 1af857e to 69a22eb Compare April 9, 2025 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant