在m上安装libicu dev

2024-06-16 10:04:18 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在mac上安装libicu dev。这是文档中推荐的说明

sudo apt-get install python-numpy libicu-dev

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

我在用水蟒,但它似乎总是吐出

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

错误


Tags: install文档devnumpyhttpgetmacreadthedocs
3条回答

对我来说,只需安装和链接brew,这个简单的答案是行不通的,所以我找到了下面的解决方案来让它工作:

1)使用brew安装icu4c

brew install icu4c

2)检查版本:

ls /usr/local/Cellar/icu4c/

提示如下: 59.1

3)执行下面的命令,替换上一步的正确版本(第一行只有整数部分,第二行和第三行有小数部分):

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)最后为pyicu安装python包:

pip install pyicu

我刚让PyICU安装在OSX上,因为同样的错误,它失败了。以下是我的建议:

  1. 安装homebrew(OSX的包管理器)
  2. brew install icu4c安装库;可能已经安装
  3. 验证是否存在必需的include目录:ls -l /usr/local/opt/icu4c/include/
  4. 如果没有该目录,则可能需要重新安装icu4u。我发现必须执行以下操作:
    1. brew remove icu4c
    2. brew install icu4c
  5. 试着安装polyglot看看它是否能找到icu4c:pip install polyglot
  6. 如果仍有问题,可以尝试指定库位置:CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install polyglot

编辑:有进一步的变化。我目前安装icu的过程:

  1. brew install icu4c
  2. brew link icu4c --force
  3. ICU_VERSION=<BREW_ICU_VERSION> CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install pyicu
brew install icu4c
brew link icu4c --force

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

相关问题 更多 >