On build fail due to `pkg-config` not being installed, error message is unhelpful
Created by: iwsfutcmd
Problem
I was recently installing PyICU on a new Ubuntu 19.04 machine that did not have pkg-config
installed. The error message was as follows:
ERROR: Command errored out with exit status 1:
command: /home/iwsfutcmd/.virtualenvs/panlex/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0x2am18z/pyicu-binary/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0x2am18z/pyicu-binary/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: /tmp/pip-install-0x2am18z/pyicu-binary/
Complete output (32 lines):
Traceback (most recent call last):
File "/tmp/pip-install-0x2am18z/pyicu-binary/setup.py", line 43, in <module>
ICU_VERSION = os.environ['ICU_VERSION']
File "/home/iwsfutcmd/.virtualenvs/panlex/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 "/tmp/pip-install-0x2am18z/pyicu-binary/setup.py", line 46, in <module>
ICU_VERSION = check_output(('icu-config', '--version')).strip()
File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/usr/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/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 "/tmp/pip-install-0x2am18z/pyicu-binary/setup.py", line 53, 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.
This implies that either ICU_VERSION
needs to be set, or icu-config
is missing. Being that icu-config
is deprecated, and it seems strange to have to set an environment variable to install a Python package (especially as I hadn't needed to before), this had stumped me until I looked into setup.py
and realized it was due to the machine not having pkg-config
installed.
Solution
Change the error message to:
Please install pkg-config on your system or set the ICU_VERSION environment variable to the version of ICU you have installed.