Pip can't install pyicu
Asked Answered
B

4

10

I am running a AWS that runs Ubuntu 20.04. I am trying to install the package pyicu, but I am facing problems. I tried running sudo apt install libicu-dev, but I still can't install pyicu. I am not able to install brew on the aws server. Any other suggestions? This is the erro message:

    ERROR: Command errored out with exit status 1:
     command: /root/dev/big5_rest/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-se360cxw/pyicu/setup.py'"'"'; __file__='"'"'/tmp/pip-install-se360cxw/pyicu/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-se360cxw/pyicu/pip-egg-info
         cwd: /tmp/pip-install-se360cxw/pyicu/
    Complete output (53 lines):
    Traceback (most recent call last):
      File "/tmp/pip-install-se360cxw/pyicu/setup.py", line 63, in <module>
        ICU_VERSION = os.environ['ICU_VERSION']
      File "/usr/lib/python3.8/os.py", line 675, in __getitem__
        raise KeyError(key) from None
    KeyError: 'ICU_VERSION'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/tmp/pip-install-se360cxw/pyicu/setup.py", line 66, in <module>
        ICU_VERSION = check_output(('icu-config', '--version')).strip()
      File "/tmp/pip-install-se360cxw/pyicu/setup.py", line 19, in check_output
        return subprocess_check_output(popenargs)
      File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
      File "/usr/lib/python3.8/subprocess.py", line 489, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'icu-config'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/tmp/pip-install-se360cxw/pyicu/setup.py", line 69, in <module>
        ICU_VERSION = check_output(('pkg-config', '--modversion', 'icu-i18n')).strip()
      File "/tmp/pip-install-se360cxw/pyicu/setup.py", line 19, in check_output
        return subprocess_check_output(popenargs)
      File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
      File "/usr/lib/python3.8/subprocess.py", line 489, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'pkg-config'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-se360cxw/pyicu/setup.py", line 71, in <module>
        raise RuntimeError('''
    RuntimeError:
    Please install pkg-config on your system or set the ICU_VERSION environment
    variable to the version of ICU you have installed.
    
    (running 'icu-config --version')
    (running 'pkg-config --modversion icu-i18n')
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Benefice answered 12/7, 2021 at 15:16 Comment(0)
S
6

This seems to be a known issue with PyICU. Contrary to the error message and recommendations on that thread, installing pkg-config and libicu-dev didn't fix the issue for me. Only installing python3-icu (as recommended in the official PyICU docs) finally fixed it.

Spun answered 26/11, 2021 at 16:31 Comment(0)
N
4

install 3 package solved this for me!

sudo apt install libicu-dev python3-icu pkg-config

Norse answered 30/8, 2023 at 6:56 Comment(1)
Please avoid duplicate answers. @Spun said discussed "installing python3-icu," as well, along with the other mentioned packages. Please don't post an answer unless you actually have something new to contribute. You can show your support for an original answer by upvoting.Ochoa
R
0
  1. Just read what you long output actually suggests

Please install pkg-config on your system or set the ICU_VERSION environment variable to the version of ICU you have installed.

  1. It is common that the latest package version or using on the latest OS may cause problem, so just raise issue to authors https://gitlab.pyicu.org/main/pyicu/-/issues
Ragan answered 26/7, 2021 at 2:33 Comment(0)
U
0

What fixed it for me was

brew install pkg-config icu4c

export PATH="/opt/homebrew/opt/icu4c/bin:/opt/homebrew/opt/icu4c/sbin:$PATH"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/homebrew/opt/icu4c/lib/pkgconfig"

I'm working on a Mac M1. So if you are also working on an Intel Mac, the paths are slightly different. See https://gitlab.pyicu.org/main/pyicu#installing-pyicu

Thanks outofthecave for pointing to the documentation!

Unblown answered 26/1 at 13:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.