kaldi icon indicating copy to clipboard operation
kaldi copied to clipboard

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

Open waveywhite opened this issue 1 year ago • 2 comments

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

waveywhite avatar Jul 01 '24 11:07 waveywhite

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.

aaronchantrill avatar Jul 02 '24 14:07 aaronchantrill

For anyone looking, I added this line to the Dockerfile before make -j $(nproc)

sed -i '/have python2.7/,+4d' extras/check_dependencies.sh

danijel3 avatar Jul 10 '24 13:07 danijel3

Thanks, that needs to be fixed. Python 2 has been dead for a long time.

kkm000 avatar Aug 28 '24 15:08 kkm000

I believe this was resolved in my recent changes

jtrmal avatar Sep 16 '24 05:09 jtrmal

I can confirm the recent changes solve this issue.

danijel3 avatar Sep 16 '24 17:09 danijel3

great, thanks for the report, closing this issue

jtrmal avatar Sep 16 '24 17:09 jtrmal