pythonpipcrf

Cannot install pystruct


I am trying to install pystruct in a Google colab notebook. I ran the command !pip install pystruct but it gave me the following error:

Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting pystruct
  Using cached pystruct-0.3.2.tar.gz (5.6 MB)
Requirement already satisfied: ad3 in /usr/local/lib/python3.7/dist-packages (from pystruct) (2.2.1)
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from pystruct) (1.21.6)
Building wheels for collected packages: pystruct
  Building wheel for pystruct (setup.py) ... error
  ERROR: Failed building wheel for pystruct
  Running setup.py clean for pystruct
Failed to build pystruct
Installing collected packages: pystruct
    Running setup.py install for pystruct ... error
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-02lv77ji/pystruct_dc17de7a2ad6430496ef5c82985a0a60/setup.py'"'"'; __file__='"'"'/tmp/pip-install-02lv77ji/pystruct_dc17de7a2ad6430496ef5c82985a0a60/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-tw042u_g/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/pystruct Check the logs for full command output.

Can someone please help me install it or suggest an alternate library for CRF in python.


Solution

  • Use these commands to install pystruct

    git clone https://github.com/pystruct/pystruct && cd pystruct
    curl https://patch-diff.githubusercontent.com/raw/pystruct/pystruct/pull/221.patch | git apply
    pip install .
    

    credit: https://github.com/pystruct/pystruct/issues/237#issuecomment-661648379