rakuri255 / UltraSinger

AI based tool to convert vocals lyrics and pitch from music to autogenerate Ultrastar Deluxe, Midi and notes. It automatic tapping, adding text, pitch vocals and creates karaoke files.
MIT License
290 stars 26 forks source link

Remove `src.` from module import: ModuleNotFoundError: No module named 'src' (on Windows) #71

Closed achimmihca closed 1 year ago

achimmihca commented 1 year ago

I installed dependencies successfully and changed to the virtual environment.

But when I try to run the main file, then I get

Traceback (most recent call last):
  File "F:\Dev\Projects\GitHub\UltraSinger\src\UltraSinger.py", line 13, in <module>
    from src.modules import os_helper
ModuleNotFoundError: No module named 'src'

Tried to start the code from F:\Dev\Projects\GitHub\UltraSinger\src and from F:\Dev\Projects\GitHub\UltraSinger but both fail.

Looking at the code, I found that modules are referenced for example with from src.modules.Audio.denoise.

Obviously this works for you, which I think is weird. VSCode also does not complain. But on Windows I have to remove the src. part from the import to make it work.

It's been a while since I did stuff with Python, but in Dedo Mouse I also referenced modules relative to the root code file.

Here, the root code file is UltraSinger.py, which is already in the src folder. Thus, other modules and files need to be referenced from this folder such that from src.modules.Audio.denoise should be written as from from modules.Audio.denoise.

I tested this and when I replace all from src. with from, then it works fine.

Please, check if it still works for you when you remove src. from the imports.

rakuri255 commented 1 year ago

Ok thanks for the info, will look into it. I use PyCharm and it works with venv and conda.

stripu commented 1 year ago

I had this error, but i copied all the files out of the src folder into the root and all runs well

64nd3r0lf commented 1 year ago

I had this error and fixed it by adding sys.path.append(“C:\\path\\to\\dir”) to the UltraSinger.py

achimmihca commented 1 year ago

The suggested solutions are workarounds to the issue.

The proper solution would be to fix the imports by removing the 'src.' part.

I can create a PR this weekend

rakuri255 commented 1 year ago

This should do it: e74c35ee965b5f19b70b579490f5841f6ca29d35

rakuri255 commented 1 year ago

According to discord chat it works now

rakuri255 commented 1 year ago

Now tests are broken 🙈

achimmihca commented 1 year ago

Question is where pytest is looking for modules

I suggest to look at a repo on GitHub that can be used as template.

rakuri255 commented 1 year ago

@achimmihca thanks. pyproject.toml does the trick for the tests. __init__.py is already in the CI branch