ttm / music

music is a python package for making sounds and music
MIT License
52 stars 9 forks source link

Circular import when importing the library #16

Closed vivaansinghvi07 closed 4 months ago

vivaansinghvi07 commented 1 year ago
import music

gives the following error:

ImportError                               Traceback (most recent call last)
Cell In[5], line 2
      1 ### Basic usage
----> 2 import music as M, numpy as n
      3 T = M.tables.Basic()
      4 H = M.utils.H

File .venv/lib/python3.9/site-packages/music/__init__.py:1
----> 1 from . import utils, tables, synths, effects, structures, singing, core
      2 from . import legacy

ImportError: cannot import name 'structures' from partially initialized module 'music' (most likely due to a circular import)
firasm commented 7 months ago

I am getting these errors while importing as well @ttm ! Would appreciate any help to get this resolved. Thanks!

filippofabbriprog commented 4 months ago

I am getting the same error... anyone has got a fix ? Thanks !

vivaansinghvi07 commented 4 months ago

Hey! Looking at this almost a year late, and it seems like instead of doing

import music

you need to do:

import sys
keys=tuple(sys.modules.keys())
for key in keys:
    if "music" in key:
        del sys.modules[key]
import music

according to the startup.py file. Hope this helps!

vivaansinghvi07 commented 4 months ago

Upon further inspection this doesn't seem to work anymore. Maybe Python 3.11 is the wrong version?

vivaansinghvi07 commented 4 months ago

Looks like it - downgrading to Python3.9 fixed this issue. Seems like they changed how modules work, making that code obsolete in later versions of Python

filippofabbriprog commented 4 months ago

Thank you very much for your help ! I'll try python 3.9 then !

ttm commented 4 months ago

we will be updating the library this week on PyPI. It is a major update. I believe this is solved.

Il giorno dom 9 giu 2024 alle ore 11:12 filippofabbriprog < @.***> ha scritto:

Thank you very much for your help ! I'll try python 3.9 then !

— Reply to this email directly, view it on GitHub https://github.com/ttm/music/issues/16#issuecomment-2156406894, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4LHLHXC5GGKRBC74OIBLZGQMBLAVCNFSM6AAAAABI76MDW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGQYDMOBZGQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Renato Fabbri

filippofabbriprog commented 4 months ago

we will be updating the library this week on PyPI. It is a major update. I believe this is solved. Il giorno dom 9 giu 2024 alle ore 11:12 filippofabbriprog < @.> ha scritto: Thank you very much for your help ! I'll try python 3.9 then ! — Reply to this email directly, view it on GitHub <#16 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4LHLHXC5GGKRBC74OIBLZGQMBLAVCNFSM6AAAAABI76MDW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGQYDMOBZGQ . You are receiving this because you were mentioned.Message ID: @.> -- Renato Fabbri --

Awesome ! Thanks !

Grazie Renato ! Bellissima notizia !

PS ma siamo cugini ? : -) Tu di dove sei? Mio nonno era di Bologna...

jacopodonati commented 4 months ago

Hi everyone! The library has been updated and that problem’s solved. Can you check it out?

As you can see from the PyPI page, this is a 1.0b5. Some bugs have been squeezed out, but it’s still a beta, so feel free to open new issues if something’s not working as intended.

👋🏻

ttm commented 4 months ago

I hope it is solved for everyone. Please let us know what you think about this major version update. I'll close this issue for now.

@filippofabbriprog , I grew up in Brazil, but in fact I have an ancestor from Emilia-Romagna. We can take this conversation elsewhere, although I don't know if github enables direct communication.