Python/Debugging

poetry 환경 내에서 fasttext 설치 오류 해결 방법

jimmy_AI 2024. 4. 8. 23:04
반응형

오류 개요

poetry로 관리하는 패키지의 의존성으로 fasttext 모듈을 설치하는 과정에서

다음과 같은 오류가 발생하였습니다.

Using version ^0.9.2 for fasttext

Updating dependencies
Resolving dependencies... (0.6s)

Package operations: 1 install, 0 updates, 0 removals

  - Installing fasttext (0.9.2): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel
  
  /tmp/tmpp1lp42ow/.venv/bin/python: No module named pip
  Traceback (most recent call last):
    File "<string>", line 38, in __init__
  ModuleNotFoundError: No module named 'pybind11'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/home/ubuntu/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/ubuntu/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/ubuntu/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/tmpp1lp42ow/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/tmpp1lp42ow/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
      self.run_setup()
    File "/tmp/tmpp1lp42ow/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/tmp/tmpp1lp42ow/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 72, in <module>
    File "<string>", line 41, in __init__
  RuntimeError: pybind11 install failed.
  

  at ~/.local/lib/python3.10/site-packages/poetry/installation/chef.py:164 in _prepare
      160│ 
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│ 
      163│             if error is not None:
    → 164│                 raise error from None
      165│ 
      166│             return path
      167│ 
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with fasttext (0.9.2) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "fasttext (==0.9.2)"'.

 

poetry add fasttext 명령어를 시도하는 과정 내에서

위와 같이 pybind11 모듈과 관련한 오류가 발생하면서 설치에 실패하였습니다.

 

출력 부분 맨 끝에 적힌 pip wheel --no-cache-dir --use-pep517 "fasttext (==0.9.2)

문구를 시도해보았지만 마찬가지로 소용이 없었습니다.

 

 

해결 방법

pyproject.toml 파일을 연 뒤, 호환되는 fasttext 버전의 레포를 명시해주고,

다시 poetry install을 시도하였더니 해당 모듈을 정상적으로 이용할 수 있었습니다.

 

파일 내에서 fasttext의 의존성과 관련된 부분을 다음과 같이 추가해주시면 됩니다.

[tool.poetry.dependencies]
python = "^3.9"
fasttext = {git = "https://github.com/cfculhane/fastText.git"}