1

I want to install LayoutLM in Google Colaboratory

First, I have cloned the LayoutLM from this GitHub repository

https://github.com/microsoft/unilm.git

After that, I will install the LayoutLM by running its setup.py file by running this code block:

%%bash
cd /content/drive/MyDrive/LayoutLMMM/SROIE2019-20210928T080219Z-001/SROIE2019
# git clone https://github.com/microsoft/unilm.git
cd unilm/layoutlm/deprecated
pip install .

However, when i tried to run the script, an error occurs

Successfully built layoutlm sacremoses
Failed to build tokenizers
  error: subprocess-exited-with-error
  
  × Building wheel for tokenizers (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

As I locate what library is causing the error, I found out that the tokenizers library in the transformers of HuggingFace is returning this error.

I have tried modifying the setup file by omitting the transformers library and modified the setup script of transformers to install the latest version of tokenizer to check if it can fix the error. Yes, this method works however, the results are not accurate.

How can I install the LayoutLM without the building wheel for tokenizers did not run successfully error?

Scezui
  • 21
  • 4

1 Answers1

0

The issue lies with the tokenizer version 0.7 being incompatible with the python 3.10. In my case, I have tried to change the python version to 3.7.0 and I was able to install it without any issues. To do this in Google Colab, I have run these series of code blocks:

This code block will install python 3.7

!sudo apt-get install python3.7
!sudo apt-get update -y

This code block will switch the python version into version 3.7

!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
!sudo update-alternatives --config python3

This code block will install the pip

!sudo apt install python3-pip

With this, the layoutlm can be installed without the error

Scezui
  • 21
  • 4