bistring icon indicating copy to clipboard operation
bistring copied to clipboard

Problems with PyICU when installing bistring 0.4.0 with pip

Open outofthecave opened this issue 3 years ago • 4 comments

Summary

I ran into what's apparently a known issue with installing PyICU over pip while trying to pip install bistring==0.4.0. 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.

This is obviously not an issue with bistring itself, but it makes it difficult to install bistring because the ICU dependency can't be automatically installed by pip. If there is nothing else that can be done about it, maybe a note about this could at least be added to the Readme file, so people can avoid the frustration of running into the pip error?

More Details

Here is the output I got from pip install bistring==0.4.0:

Collecting bistring==0.4.0
  Downloading bistring-0.4.0-py3-none-any.whl (22 kB)
Collecting pyicu
  Downloading PyICU-2.8.tar.gz (299 kB)
     |████████████████████████████████| 299 kB 2.1 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /tmp/tmprkr9c6uy get_requires_for_build_wheel /tmp/tmp5tnhtmha
       cwd: /tmp/pip-install-x_54yndb/pyicu
  Complete output (64 lines):
  (running 'icu-config --version')
  (running 'pkg-config --modversion icu-i18n')
  Traceback (most recent call last):
    File "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 "setup.py", line 66, in <module>
      ICU_VERSION = check_output(('icu-config', '--version')).strip()
    File "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 "setup.py", line 69, in <module>
      ICU_VERSION = check_output(('pkg-config', '--modversion', 'icu-i18n')).strip()
    File "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 "/tmp/tmprkr9c6uy", line 280, in <module>
      main()
    File "/tmp/tmprkr9c6uy", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/tmp/tmprkr9c6uy", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-p3nxngyx/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/tmp/pip-build-env-p3nxngyx/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-p3nxngyx/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "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.

  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 /tmp/tmprkr9c6uy get_requires_for_build_wheel /tmp/tmp5tnhtmha Check the logs for full command output

outofthecave avatar Nov 26 '21 16:11 outofthecave

pip install bistring==0.4.0 works for me on Arch Linux. Are you using Ubuntu? I will try it in an Ubuntu container.

tavianator avatar Nov 26 '21 18:11 tavianator

a recent CI passed too https://github.com/microsoft/bistring/runs/4336640670?check_suite_focus=true and that used Ubuntu 20.04.3. Although, that image is fairly bloated so may of had what was needed already.

Mmdixon avatar Nov 26 '21 18:11 Mmdixon

Yes, I'm on Ubuntu 20.04.

outofthecave avatar Nov 26 '21 18:11 outofthecave

So on a fresh Ubuntu 20.04 image, I needed to do

# apt install libicu-dev pkg-config

before pip install bistring would work. But you're right that this is better (faster):

# apt install python3-icu

I'll add this to the docs somewhere.

tavianator avatar Mar 29 '22 16:03 tavianator