googlefonts / pyfontaine

Python tool to check font files for language/character set support
https://github.com/googlefonts/pyfontaine
GNU General Public License v3.0
103 stars 22 forks source link

Installation issue: "RuntimeError: Please set the ICU_VERSION environment variable to the version of ICU you have installed." #109

Closed arrowtype closed 3 years ago

arrowtype commented 5 years ago

I'm having a lot of trouble installing this, and I'm not quite sure why. I've talked to a couple of others who had no issues.

I've followed the README instructions, but when I get to setting flags and pip installing, I get the following set of errors:

~/type-repos/recursive  master āœ”                                                                                                                                                                                                
šŸ‘‰ CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install pyicu;
Collecting pyicu
  Using cached https://files.pythonhosted.org/packages/e9/35/211ffb949c68e688ade7d40426de030a24eaec4b6c45330eeb9c0285f43a/PyICU-2.3.1.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /Users/stephennixon/type-repos/recursive/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/setup.py'"'"'; __file__='"'"'/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/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 /private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/pip-egg-info
         cwd: /private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/
    Complete output (53 lines):
    Package icu-i18n was not found in the pkg-config search path.
    Perhaps you should add the directory containing `icu-i18n.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'icu-i18n' found
    (running 'icu-config --version')
    (running 'pkg-config --modversion icu-i18n')
    Traceback (most recent call last):
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/setup.py", line 62, in <module>
        ICU_VERSION = os.environ['ICU_VERSION']
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/os.py", line 678, 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 "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/setup.py", line 65, in <module>
        ICU_VERSION = check_output(('icu-config', '--version')).strip()
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/setup.py", line 18, in check_output
        return subprocess_check_output(popenargs)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
        **kwargs).stdout
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 472, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
        restore_signals, start_new_session)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'icu-config': 'icu-config'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/setup.py", line 68, in <module>
        ICU_VERSION = check_output(('pkg-config', '--modversion', 'icu-i18n')).strip()
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/setup.py", line 18, in check_output
        return subprocess_check_output(popenargs)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
        **kwargs).stdout
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 487, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '('pkg-config', '--modversion', 'icu-i18n')' returned non-zero exit status 1.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-ge2l717o/pyicu/setup.py", line 73, in <module>
        ''')
    RuntimeError:
    Please set the ICU_VERSION environment variable to the version of
    ICU you have installed.

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I tried following the advice given by adding ICU_VERSION=64.2 to my command, and ended up with another error that is a little less clear:

~/type-repos/recursive  master āœ”                                                                                                                                                                                                                       
šŸ‘‰ CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib ICU_VERSION=64.2 pip install pyicu;

Collecting pyicu
  Using cached https://files.pythonhosted.org/packages/e9/35/211ffb949c68e688ade7d40426de030a24eaec4b6c45330eeb9c0285f43a/PyICU-2.3.1.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-oiuz4ij1/pyicu/setup.py'"'"'; __file__='"'"'/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-oiuz4ij1/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 pip-egg-info
         cwd: /private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-oiuz4ij1/pyicu/
    Complete output (33 lines):

    Building PyICU 2.3.1 for ICU 64.2

    (running 'icu-config --cxxflags --cppflags')
    Could not configure CFLAGS with icu-config
    Traceback (most recent call last):
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-oiuz4ij1/pyicu/setup.py", line 173, in <module>
        _cflags, ('--cxxflags', '--cppflags'), 'CFLAGS')
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-oiuz4ij1/pyicu/setup.py", line 35, in configure_with_icu_config
        output = check_output(('icu-config',) + config_args).strip()
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-oiuz4ij1/pyicu/setup.py", line 18, in check_output
        return subprocess_check_output(popenargs)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
        **kwargs).stdout
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 472, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
        restore_signals, start_new_session)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'icu-config': 'icu-config'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/sr/fzxs628x5gbgjtwscngjdcqh0000gn/T/pip-install-oiuz4ij1/pyicu/setup.py", line 187, in <module>
        ''')
    RuntimeError:
    Please install pkg-config on your system or set the PYICU_CFLAGS environment
    variable to the flags required by the C++ compiler to find the header files
    for ICU, and possibly -std=c++11 if using ICU version >= 60

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Please install pkg-config on your system

A brew install pkg-config (and a brew reinstall pkg-config) did not change the above error message.

When I try adding -std=c++11 to the command, it fails ā€“ I'm assuming that the message is actually intending to say that I should maybe also install -std=c++11? If so, how should I do so? It's hard to find a direct answer via google.

Am I going in the right direction on this, or should I try something else? Thanks for any advice!

lianghai commented 4 years ago

I tried configuring those flags in so many ways but none of them worked. Eventually it helped to just temporarily prepend PATH according to the information provided by brew info icu4c (attached at the end):

PATH="/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:$PATH"

Then you can simply do the following without worrying about the flags at all:

pip install pyicu

This is on macOS 10.15.3 (19D76) and inside a venv.


An excerpt of the information provided by 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"
felipesanches commented 3 years ago

I've followed these instructions and it worked for me: https://github.com/googlefonts/pyfontaine/issues/109#issuecomment-604872347

dgslv commented 2 years ago

I tried configuring those flags in so many ways but none of them worked. Eventually it helped to just temporarily prepend PATH according to the information provided by brew info icu4c (attached at the end):

PATH="/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:$PATH"

Then you can simply do the following without worrying about the flags at all:

pip install pyicu

This is on macOS 10.15.3 (19D76) and inside a venv.

An excerpt of the information provided by 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"

Also worked for me on macOS.

eliheuer commented 1 year ago

export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig" fixed the issue for me. This should be in the main README.

esciara commented 11 months ago

export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig" fixed the issue for me. This should be in the main README.

Worked for me too... Would be helpful to update the README.