liebharc / homr

homr is an Optical Music Recognition (OMR) software designed to transform camera pictures of sheet music into machine-readable MusicXML format.
GNU Affero General Public License v3.0
9 stars 3 forks source link

Import error occurs when running with `python homr/main.py` #3

Closed BreezeWhite closed 4 months ago

BreezeWhite commented 4 months ago

Describe the bug

When I tried to execute python homr/main.py, it throws the following exception

Traceback (most recent call last):
  File "/home/derekwu/homr/homr/main.py", line 11, in <module>
    from . import color_adjust, download_utils
ImportError: attempted relative import with no known parent package

I can fix this by adding homr to the front of every relatively imported paths. (Ps. As there is no entrypoint for the main.py, so I added the if __name__ == '__main__': main() to the end of the file)

And this leads to further importing problems. As there are two files with names that conflict with the python built-in packages, which are homr/types.py and homr/logging.py, I have to rename these two files to other name to make it work.

What's weird for me is that if I install homr locally and directly execute homr --help, everything just work without any problem. But for local development, I am still not used to install the package locally. Instead I would execute and debug like above. Maybe it's better to describe this in README, including more instructions about how to properly setup the project.

Anyway, nice work 👍🏻

liebharc commented 4 months ago

https://github.com/liebharc/homr/commit/43b092ba44f76269865abe47438e2c759fa7cdb4 should address this, let me know what you think!

BreezeWhite commented 4 months ago

Yes! The commit fixed the problem.