【问题标题】:Can't install pyicu due to 'icu-config'由于 'icu-config' 无法安装 pyicu
【发布时间】:2017-04-21 18:51:04
【问题描述】:

我正在尝试根据此链接在 mac 上为 python 3.5 安装 pyicu https://struggley.wordpress.com/2015/07/14/installation-pyicu-on-mac-osx-yosemite/

但是,当我执行 pip3 install pyicu 时,我得到了这个错误

Collecting pyicu
Using cached PyICU-1.9.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/70/jlxmpp0n003805pmw6tfc0r80000gn/T/pip-build-7eusuic1/pyicu/setup.py", line 11, in <module>
    ICU_VERSION = subprocess.check_output(('icu-config', '--version')).strip()
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 693, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'icu-config'

我猜是因为我没有正确设置 icu-config 的路径。我认为以下两个可能是icu-config文件。

/usr/local/Cellar/icu4c/58.1/bin/icu-config
/usr/local/Cellar/icu4c/58.1/share/man/man1/icu-config.1

但是,我不知道如何设置它的路径。此外,我不知道为什么在教程可以顺利运行时出现此错误。

【问题讨论】:

标签: python macos pyicu


【解决方案1】:

只需将包含icu-config的目录添加到PATH,例如:

brew install icu4c
export PATH="/usr/local/opt/icu4c/bin:$PATH"
pip install pyicu

如果您使用pipenv,您还可以通过.env file 更新PATH。在您的项目根目录中,创建一个名为 .env 的文件,其内容如下:

PATH="/usr/local/opt/icu4c/bin:${PATH}"

然后运行:

pipenv shell
pipenv install pyicu

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。这对我有用

    brew install intltool icu4c gettext
    brew link icu4c gettext --force
    CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip3 install pyicu
    

    来源:https://github.com/Homebrew/legacy-homebrew/issues/34170

    【讨论】:

    • 酷!我之前没有安装gettext。但是在我 brew install gettext 之后,你的方法神奇地起作用了。谢谢。
    • 顺便说一句,由于我使用的是 Anaconda python 3.5,所以我使用的是 pip install,而不是 pip3 install。
    • 该解决方案有效,但我也必须执行以下操作。 1) 将 /usr/local/opt/icu4c/bin 添加到 PATH 2) 设置 ICU_VERSION
    猜你喜欢
    • 2021-09-21
    • 1970-01-01
    • 1970-01-01
    • 2015-11-05
    • 2017-04-17
    • 2020-09-22
    • 1970-01-01
    • 2019-10-01
    • 1970-01-01
    相关资源
    最近更新 更多