installing libicu-dev on mac

2019-01-18 06:09发布

问题:

how do i install libicu-dev on mac. This is the instruction recommended on the documentation

sudo apt-get install python-numpy libicu-dev

http://polyglot.readthedocs.org/en/latest/Installation.html

I am using anaconda but it seems to always throw up an

In file included from _icu.cpp:27:
    ./common.h:86:10: fatal error: 'unicode/utypes.h' file not found
    #include <unicode/utypes.h>

error

回答1:

I just got PyICU to install on OSX, after it was failing due to that same error. Here is what I recommend:

  1. Install homebrew (package manager for OSX)
  2. brew install icu4c # Install the library; may be already installed
  3. Verify that the necessary include directory is present: ls -l /usr/local/opt/icu4c/include/
  4. If you do not have that directory, you may need to reinstall icu4u. I found that I had to do the following:
    1. brew remove icu4c
    2. brew install icu4c
  5. Try to install polyglot to see if it can find icu4c: pip install polyglot
  6. If that still complains, you can try specifying library location: CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install polyglot


回答2:

brew install icu4c
brew link icu4c --force

https://github.com/imojiengineering/node-icu-tokenizer



回答3:

for me the simple answer with just brew install and linking does not work so I found the below solution to make it works:

1) install icu4c with brew:

brew install icu4c

2) check the version:

ls /usr/local/Cellar/icu4c/

it prompts something like: 59.1

3) execute bellow commands with substitution of proper version from previous step (first line only integer part, second and third line with decimal part):

export ICU_VERSION=59
export PYICU_INCLUDES=/usr/local/Cellar/icu4c/59.1/include
export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/59.1/lib

4) finally install python package for pyicu:

pip install pyicu