【线上问题】Ubuntu环境无法安装PyICU,KeyError ICU_VERSION,No such file or directory icu-config
1 环境信息
1.1 Ubuntu环境
1.2 Python环境
Python3.10.14
2 内容
2.1 解决方案
安装缺少的依赖。
sudo apt-get install build-essential
sudo apt-get install python3-dev
sudo apt-get install libicu-dev
sudo apt-get install pkg-config
2.2 异常提示信息
Ubuntu环境无法正常安装PyICU,安装时的异常提示信息如下:
Installing build dependencies … done
Getting requirements to build wheel … error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [58 lines of output]
(running ‘icu-config --version’)
(running ‘pkg-config --modversion icu-i18n’)
Traceback (most recent call last):
File “”, line 89, in
File “/usr/lib/python3.10/os.py”, line 680, 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 “”, line 92, in
File “”, line 19, in check_output
File “/usr/lib/python3.10/subprocess.py”, line 421, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File “/usr/lib/python3.10/subprocess.py”, line 503, in run
with Popen(*popenargs, **kwargs) as process:
File “/usr/lib/python3.10/subprocess.py”, line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.10/subprocess.py”, line 1863, 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 “”, line 96, in
File “”, line 19, in check_output
File “/usr/lib/python3.10/subprocess.py”, line 421, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File “/usr/lib/python3.10/subprocess.py”, line 503, in run
with Popen(*popenargs, **kwargs) as process:
File “/usr/lib/python3.10/subprocess.py”, line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.10/subprocess.py”, line 1863, 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 “…/.venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”, line 353, in
main()
File “…/.venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”, line 335, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
File “…/.venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”, line 118, in get_requires_for_build_wheel
return hook(config_settings)
File “/tmp/pip-build-env-douf9rl9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py”, line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File “/tmp/pip-build-env-douf9rl9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py”, line 304, in _get_build_requires
self.run_setup()
File “/tmp/pip-build-env-douf9rl9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py”, line 320, in run_setup
exec(code, locals())
File “”, line 99, in
RuntimeError:
Please install pkg-config on your system or set the ICU_VERSION environment
variable to the version of ICU you have installed.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
3 原因
安装PyICU缺少依赖,
如g++、libicu-dev等。
4 解决方案
安装缺少的依赖。
纯文本:
sudo apt-get install build-essential
sudo apt-get install python3-dev
sudo apt-get install libicu-dev
sudo apt-get install pkg-config
格式化:
sudo apt-get install build-essential
sudo apt-get install python3-dev
sudo apt-get install libicu-dev
sudo apt-get install pkg-config
5 成功安装
pip install pyicu==2.14 -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
pip install pyicu==2.14 -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
本文地址:https://www.vps345.com/8136.html