kaldi-asr / kaldi

kaldi-asr/kaldi is the official location of the Kaldi project.
http://kaldi-asr.org
Other
14.12k stars 5.31k forks source link

egs/chime6/s5c_track2/local/ts-vad/diarize_TS-VAD_itX.sh: use python3 #4766

Closed boeddeker closed 2 years ago

boeddeker commented 2 years ago

I got the error

Traceback (most recent call last):
  File "local/ts-vad/convert_prob_to_rttm.py", line 32, in <module>
    import regex as re
ImportError: No module named regex

for the CHiME-6 recipe and I had issues to figure out, why I get this error, because the first line of that script says it runs with python3 (I installed in every python3 env regex, but it didn't helped).

So I printed the python version, and it said, it's python2. Then I tried to install regex in python2, but there I got errors like:

$ python2 -m pip install regex
...
regex_3/_regex.c:755:15: error: ‘Py_UCS1’ undeclared (first use in this function); did you mean ‘Py_UCS4’?
...
regex_3/_regex.c:26218:5: error: ‘PyModuleDef_HEAD_INIT’ undeclared here (not in a function)
...

I think it is easier to change to python3, especially since eol was 2020 for python2.

This PR changes all python calls in diarize_TS-VAD_itX.sh to use python3, as indicated in the first line of the script.

desh2608 commented 2 years ago

I think it would work if you just run the script inside a conda python3 environment (conda create -n my_env python=3.8), since in that case the python command defaults to python3.

boeddeker commented 2 years ago

I think it would work if you just run the script inside a conda python3 environment (conda create -n my_env python=3.8), since in that case the python command defaults to python3.

My default python is python3.9 and my OS has python3.8 as default. As far as I know, kaldi tries to "fix" an environment, if python 2.7 is not the default python. I found .../kaldi/tools/python/python -> /usr/bin/python2.7 in my python environment (It's a fresh kaldi folder from this year).

Is there a reason, why kaldi doesn't use explicit python3 and python2?

jtrmal commented 2 years ago

I think mostly a history. Plus I think there is no PEP guaranteeing python2 will exist (I might be wrong, tho) y.

On Wed, Jul 20, 2022 at 10:30 AM Christoph Boeddeker < @.***> wrote:

I think it would work if you just run the script inside a conda python3 environment (conda create -n my_env python=3.8), since in that case the python command defaults to python3.

My default python is python3.9 and my OS has python3.8 as default. As far as I know, kaldi tries to "fix" an environment, if python 2.7 is not the default python. I found .../kaldi/tools/python/python -> /usr/bin/python2.7 in my python environment (It's a fresh kaldi folder from this year).

Is there a reason, why kaldi doesn't use explicit python3 and python2?

— Reply to this email directly, view it on GitHub https://github.com/kaldi-asr/kaldi/pull/4766#issuecomment-1190360288, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKYX6ZIM4IXIV34OYFVYDVVAEQBANCNFSM54BGDZEA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jtrmal commented 2 years ago

IIRC, last time I was looking at that, there wasn't any easy way how to guarantee python will be always version 2 and python2/python3 will exist y.

On Wed, Jul 20, 2022 at 2:51 PM Jan Yenda Trmal @.***> wrote:

I think mostly a history. Plus I think there is no PEP guaranteeing python2 will exist (I might be wrong, tho) y.

On Wed, Jul 20, 2022 at 10:30 AM Christoph Boeddeker < @.***> wrote:

I think it would work if you just run the script inside a conda python3 environment (conda create -n my_env python=3.8), since in that case the python command defaults to python3.

My default python is python3.9 and my OS has python3.8 as default. As far as I know, kaldi tries to "fix" an environment, if python 2.7 is not the default python. I found .../kaldi/tools/python/python -> /usr/bin/python2.7 in my python environment (It's a fresh kaldi folder from this year).

Is there a reason, why kaldi doesn't use explicit python3 and python2?

— Reply to this email directly, view it on GitHub https://github.com/kaldi-asr/kaldi/pull/4766#issuecomment-1190360288, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKYX6ZIM4IXIV34OYFVYDVVAEQBANCNFSM54BGDZEA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

boeddeker commented 2 years ago

Thanks for the explanation/

I think mostly a history. Plus I think there is no PEP guaranteeing python2 will exist (I might be wrong, tho)

That was my guess. But now some kaldi scripts use python and expect it to be python3. I never checked if there is a guarantee that python2 exist. But that is an easy thing to fix. I started with python3 and I just saw, that there is always a python2. Since python2 is eol, I think it will never be removed, but I don't know, when they started to use it and if old systems are still used.

IIRC, last time I was looking at that, there wasn't any easy way how to guarantee python will be always version 2 and python2/python3 will exist

But now sometimes users use different python versions in kaldi. It sounds like desh2608 has python3 as default, while in my KALDI_ROOT the symlink in tools makes python2 the default. So I am struggling, just to execute the baseline recipe.

I think it is relative easy to guarantee that python2/python3 exist: Just create more symlinks in kaldi/tools/python.

But using python2/3 instead of python is a general coding convention and probably difficult to change and convince people. (I think python3 will stay forever, because too many people use it) If I hit more cases, where python2 doesn't work, I will create more PRs.

jtrmal commented 2 years ago

yeah, it will be great if you do that... python3 is in PEP now, I believe, so should be just fine. y.

On Wed, Jul 20, 2022 at 4:13 PM Christoph Boeddeker < @.***> wrote:

Thanks for the explanation/

I think mostly a history. Plus I think there is no PEP guaranteeing python2 will exist (I might be wrong, tho)

That was my guess. But now some kaldi scripts use python and expect it to be python3. I never checked if there is a guarantee that python2 exist. But that is an easy thing to fix. I started with python3 and I just saw, that there is always a python2. Since python2 is eol, I think it will never be removed, but I don't know, when they started to use it and if old systems are still used.

IIRC, last time I was looking at that, there wasn't any easy way how to guarantee python will be always version 2 and python2/python3 will exist

But now sometimes users use different python versions in kaldi. It sounds like desh2608 has python3 as default, while in my KALDI_ROOT the symlink in tools makes python2 the default. So I am struggling, just to execute the baseline recipe.

I think it is relative easy to guarantee that python2/python3 exist: Just create more symlinks in kaldi/tools/python.

But using python2/3 instead of python is a general coding convention and probably difficult to change and convince people. (I think python3 will stay forever, because too many people use it) If I hit more cases, where python2 doesn't work, I will create more PRs.

— Reply to this email directly, view it on GitHub https://github.com/kaldi-asr/kaldi/pull/4766#issuecomment-1190710667, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKYX3TT23DVYMFA3LLIUDVVBMWLANCNFSM54BGDZEA . You are receiving this because you commented.Message ID: @.***>