aparrish / pronouncingpy

A simple interface for the CMU pronouncing dictionary
BSD 3-Clause "New" or "Revised" License
298 stars 42 forks source link

python3.11 #63

Open zhuokun opened 5 months ago

zhuokun commented 5 months ago

AttributeError: partially initialized module 'pronouncing' has no attribute 'rhymes' (most likely due to a circular import)

hugovk commented 5 months ago

Please can you show the full error traceback and a small snippet of code that causes this?

mdmunoz commented 4 months ago

I'm also having trouble with 3.11.7. Downgrading to 3.10.13 works. It looks like something changed with calling string methods on items when iterating over file handles opened 'rb'.

pronouncing 0.2.0 cmudict 0.4.0 (I also tried the latest cmudict)

  File "/opt/homebrew/lib/python3.11/site-packages/pronouncing/__init__.py", line 51, in init_cmu
    pronunciations = parse_cmu(filehandle)
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pronouncing/__init__.py", line 28, in parse_cmu
    if line.startswith(';'):
       ^^^^^^^^^^^^^^^^^^^^
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
hugovk commented 4 months ago

Can you share a minimal code example that causes that?

mdmunoz commented 4 months ago

It was just

import pronouncing as P
P.init_cmu()

However, I just tried force-reinstalling pronouncing 0.2.0 with pip on 3.11 and it works. Something must have been wrong with my particular installation.