kaldi-asr / kaldi

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

Can't build tools on Ubuntu 24.04 due to dependency on python 2.7 #4922

Open waveywhite opened 5 days ago

waveywhite commented 5 days ago

I tried building the Kaldi tools on Ubuntu 24.04 using the following method:

  1. clone https://github.com/kaldi-asr/kaldi
  2. cd kaldi/tools
  3. run make
  4. install requested dependencies
  5. run make again to build

However, I came unstuck on the python2.7 dependency. I found that this is not available from the standard Ubuntu repositories or on a 3rd party PPA. Other linux distributions have dropped or are dropping python 2.7 imminently.

Please could the version of python required be bumped up to python 3.x

aaronchantrill commented 4 days ago

I don't think python 2.7 is really required anymore. At least, I haven't run into a problem without it, but I haven't run every single script either.

To install kaldi without python2.7, I just comment out the sections of tools/extras/check_dependencies.sh that require it. Go to line 96 or so and you should see a block like:

if ! have python2.7; then
  echo "$0: python2.7 is not installed"
  add_packages python27 python2.7
  pythonok=false
fi

just use hashmarks to comment out the code:

#if ! have python2.7; then
#  echo "$0: python2.7 is not installed"
#  add_packages python27 python2.7
#  pythonok=false
#fi

then go to line 111 and comment out the following block like so:

#if $pythonok && ! have python2; then
#  mkdir -p $PWD/python
#  echo "$0: python2.7 is installed, but the python2 binary does not exist." \
#       "Creating a symlink and adding this to tools/env.sh"
#  ln -s $(command -v python2.7) $PWD/python/python2
#  echo "export PATH=$PWD/python:\${PATH}" >> env.sh
#fi

When you run it now, you get a message:

extras/check_dependencies.sh: WARNING python 2.7 is not the default python. We fixed this by adding a correct symlink more prominently on the path.
 ... If you really want to use python 3.10.14 as default, add an empty file ~/kaldi/tools/python/.use_default_python and run this script again.

Go ahead and touch python/.use_default_python and run the script again.

At this point, it should stop bugging you about python 2.7.

I've been meaning to go through the code and see if I can figure out what might still require python 2.7 and update it, especially now that distros are dropping python 2.7.