29

我一直在尝试在我的 Mac 上安装 musicbrainz 服务器,并且有一个步骤是我必须安装 pip pyicu。我不断收到此错误:

Collecting pyicu
Downloading PyICU-1.9.5.tar.gz (181kB)
100% |████████████████████████████████| 184kB 515kB/s 
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-build-E50o2C/pyicu/setup.py", line 11, in <module>
    ICU_VERSION = subprocess.check_output(('icu-config', '--version')).strip()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-E50o2C/pyicu/

我尝试下载 ez_setup.py 并执行 python ez_setup.py。我已经升级了 setuptools 并分别下载了它们。我不确定还有什么可以尝试的。请帮忙!

4

9 回答 9

40

我在 ubuntu 14.04 和 16.04 上遇到了这个问题。要解决此问题,请安装 libicu-dev 然后再次尝试安装。我做了

$sudo apt install libicu-dev
$pip install pyicu
于 2017-01-20T14:34:56.270 回答
21

尝试安装 polyglot 时,我在 Mac 上遇到了这个问题(polyglot 需要 pyicu)。以下为我解决了这个问题。

# Install icu
brew install icu4c

# check newest version
ls /usr/local/Cellar/icu4c/

# Edit pyicu installer to work
git clone https://github.com/ovalhub/pyicu.git

# edit setup.py not to query for the version, i.e. change
# ICU_VERSION = subprocess.check_output(('icu-config', '--version')).strip()
# to whatever your version is, e.g.
# ICU_VERSION = '57.1'

# Install pyicu
env LDFLAGS=-L/usr/local/opt/icu4c/lib CPPFLAGS=-I/usr/local/opt/icu4c/include DYLD_LIBRARY_PATH=-L/usr/local/opt/icu4c/lib python setup.py build
env LDFLAGS=-L/usr/local/opt/icu4c/lib CPPFLAGS=-I/usr/local/opt/icu4c/include DYLD_LIBRARY_PATH=-L/usr/local/opt/icu4c/lib sudo python setup.py install

# Change DYLD_LIBRARY_PATH (not sure if req'd)
DYLD_LIBRARY_PATH=/usr/local/Cellar/icu4c/{version, e.g. 57.1}/:$DYLD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH

# Icu works now from python, and you can proceed with polyglot
$ python
>>> import icu
$ pip install polyglot
$ python
>>> import polyglot
于 2016-12-22T11:12:23.657 回答
20

让我让它工作:

1)icu4c用brew安装:

brew install icu4c
brew link icu4c --force

2)检查版本:

ls /usr/local/Cellar/icu4c/

它提示类似: 64.2

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

export ICU_VERSION=64
export PYICU_INCLUDES=/usr/local/Cellar/icu4c/64.2/include
export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/64.2/lib

4)最后为pyicu安装python包:

pip install pyicu --upgrade

如果您在上述情况下失败(在 OS X 上已经发生在我身上10.15),您可能需要:

brew install pkg-config

export PYICU_CFLAGS=-std=c++11:-DPYICU_VER='"2.3.1"'
于 2018-02-22T11:43:22.877 回答
12

在 macOS 10.14.2 上,只需将包含的目录添加icu-configPATH对我来说就行了:

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

实际上,这是由以下建议的brew info icu4c

==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
于 2018-12-28T09:23:54.450 回答
8

以下解决方案仅适用于 MAC OSX -

尝试使用 brew 安装 pyICU:

brew install icu4c

如果它说它已经安装并且只需要链接,那么试试这个:

brew link icu4c

这会在“/usr/local/Cellar/icu4c/...”中创建相对符号链接

于 2017-03-13T10:02:10.580 回答
7

以下解决方案在 OSX 上对我有用:

# Install ucu4c via Brew
brew install icu4c

# Create relative symlinks for icu4c
brew link --force icu4c

# Install pyicu via pip
# Make sure ICU_VERSION matches the one you just installed
sudo ICU_VERSION=60.2 pip install pyicu
于 2017-12-21T10:45:08.993 回答
1

似乎icu4c打包的当前版本brew没有icu-config正确链接文件。

运行brew link icu4c --force为您提供了解决此问题的必要信息,但无法自动链接它。

$ brew link --force icu4c
Warning: Refusing to link macOS-provided software: icu4c
If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

icu4c安装完成后,您需要运行以下brew命令以icu-config进入您的路径(假设您正在运行 bash 作为您的 shell):

echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

之后,您应该能够在pyicu没有任何其他环境变量的情况下进行安装:

$ pip install --no-cache-dir pyicu
Collecting pyicu
  Downloading https://files.pythonhosted.org/packages/c2/15/0af20b540c828943b6ffea5677c86e908dcac108813b522adebb75c827c1/PyICU-2.2.tar.gz (211kB)
    100% |████████████████████████████████| 215kB 4.9MB/s 
Installing collected packages: pyicu
  Running setup.py install for pyicu ... done
Successfully installed pyicu-2.2

总之,这是我为完成这项工作而运行的命令的完整列表:

brew install icu4c
brew link icu4c --force
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install --no-cache-dir pyicu

(顺便说一句,我遇到的许多解决方案都没有使用--no-cache-dir带有 . 的选项pip install。我认为其中一些可能已经缓存了pyicu.我能够适当地复制和修复的选项。)

于 2019-02-13T14:06:20.160 回答
1

这失败了,因为这icu4c是一个仅限小桶的公式,您可以在brew info icu4c.

建议使用其他一些答案,brew link icu4c但这可能会导致macOS 已经提供的其他问题libicucore.dylib

pip install pyicu失败是因为

  • 将尝试运行icu-config命令,因此icu-config必须在 PATH 中
  • 将尝试运行pkgconfig ... icu-i18n,因此.pcicu4c 的文件必须位于PKG_CONFIG_PATH

对于 macOS,如果您不想brew link icu4c并且只想使 icu4c 可用于您的pip install命令,那么您可以这样做:

brew install pkg-config icu4c

# brew info icu4c 
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

icu-config --version # 68.2
pkg-config --modversion icu-i18n # 68.2

pip install pyicu==2.6.0 # works because icu-config in PATH and pkgconfig can find icu4c
于 2021-03-19T09:25:54.367 回答
0

我试图在 RHEL 中安装,并从 tar.gz 文件安装。以下是命令:

    /usr/local/bin/pip3 install -U setuptools
    /usr/local/bin/pip3 install -U wheel
    wget http://download.icu-project.org/files/icu4c/50.1.2/icu4c-50_1_2-src.tgz
    tar -zxvf icu4c-50_1_2-src.tgz
    cd icu
    cd source
    sudo ./configure --prefix=/usr
    sudo make
    sudo make install
    icu-config --version
    /usr/local/bin/pip3 install PyICU==2.0.6
于 2019-05-09T12:23:09.840 回答