dmort27 / epitran

A tool for transcribing orthographic text as IPA (International Phonetic Alphabet)
MIT License
625 stars 120 forks source link

import epitran shows an error #135

Closed brijeshagal closed 1 year ago

brijeshagal commented 1 year ago

Hey, my team and I are using your excellent library for text conversion to phonemes for our research paper. We are using google colab and when I import the library after installation, it returns the following error:

`Traceback (most recent call last):

File "/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py", line 3326, in run_code exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in import epitran

File "/usr/local/lib/python3.7/dist-packages/epitran/init.py", line 1, in from epitran._epitran import Epitran

File "/usr/local/lib/python3.7/dist-packages/epitran/_epitran.py", line 9, in from epitran.simple import SimpleEpitran

File "/usr/local/lib/python3.7/dist-packages/epitran/simple.py", line 116 if nondeterminisms := self._non_deterministic_mappings(gr_by_line): ^ SyntaxError: invalid syntax`

ulf1 commented 1 year ago

yes i have the same bug what was added in commit https://github.com/dmort27/epitran/commit/954f12a1d4ab153593dd19d6ed1ca25ad6e3b835

kalvinchang commented 1 year ago

:= is only valid in Python 3.8+

https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions

kalvinchang commented 1 year ago

Could you update your Python version in colab (which defaults to 3.7)?

dmort27 commented 1 year ago

In principle, we could use the old, more verose, syntax instead. Python 3.7 has not yet reached end of life, but it is quite old and more recent versions are better, if you can use them. Are you unable to work with >=3.8?

ulf1 commented 1 year ago

I think it's a bad idea to assume >=3.8 for enforcing some new but secondary python syntax change

brijeshagal commented 1 year ago

Could you update your Python version in colab (which defaults to 3.7)?

So, I did change the python version by following: StackOverflow

This changed the python version but I'm no more able to use 'pip' for installation and a few queries similar to this at: StackOverflow. I have tried all solutions in the comments but I get such an error in return:

Traceback (most recent call last): File "/usr/local/bin/pip3", line 5, in <module> from pip._internal.cli.main import main ModuleNotFoundError: No module named 'pip'

brijeshagal commented 1 year ago

Could you update your Python version in colab (which defaults to 3.7)?

So, I did change the python version by following: StackOverflow

This changed the python version but I'm no more able to use 'pip' for installation and a few queries similar to this at: StackOverflow. I have tried all solutions in the comments but I get such an error in return:

Traceback (most recent call last): File "/usr/local/bin/pip3", line 5, in <module> from pip._internal.cli.main import main ModuleNotFoundError: No module named 'pip'

So, I used another method to perform the same. Referring to: Site This on running pip install epitran or !pip install epitran throws a new error:

Traceback (most recent call last): File "/usr/local/bin/pip3", line 5, in <module> from pip._internal.cli.main import main File "/usr/lib/python3/dist-packages/pip/__init__.py", line 29, in <module> from pip.utils import get_installed_distributions, get_prog File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in <module> from pip.locations import ( File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in <module> from distutils import sysconfig ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.9/distutils/__init__.py)

kalvinchang commented 1 year ago

Our apologies for the inconvenience this has caused. 😞

brijeshagal commented 1 year ago

Since, lower versions weren't helping, changed to a higher version and this time switched to local. Local is not preferred as we need collaboration. Anyways, great library guys! I hope you work on older LTS version maintenance too! Thank You ✌

kalvinchang commented 1 year ago

We've created a new release that should be compatible with Python < 3.8 (#138) I've tested the import on Colab and it should work