sentencepiece icon indicating copy to clipboard operation
sentencepiece copied to clipboard

SentencePiece Installation: Build Wheel Failed to Run Successfully

Open Kax-Industries opened this issue 9 months ago • 17 comments

I've been attempting to install SentencePiece for some time now, but I have been unsuccessful so far. I've tried several troubleshooting steps, including redownloading CMake and using the -DCMAKE_POLICY_VERSION_MINIMUM=3.5, but the issue persists. I would appreciate any assistance in resolving this problem. Here is the error code I'm encountering:

Collecting sentencepiece Using cached sentencepiece-0.2.0.tar.gz (2.6 MB) 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 ╰─> [37 lines of output] -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:15 (cmake_minimum_required): Compatibility with CMake < 3.5 has been removed from CMake.

    Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
    to tell CMake that the project requires at least <min> but has been updated
    to work with policies introduced by <max> or earlier.

    Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.


  -- Configuring incomplete, errors occurred!
  Traceback (most recent call last):
    File "C:\Users\Kax\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module>
      main()
      ~~~~^^
    File "C:\Users\Kax\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
                               ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Kax\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 143, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\Kax\AppData\Local\Temp\pip-build-env-n8xytm7x\overlay\Lib\site-packages\setuptools\build_meta.py", line 331, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=[])
             ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Kax\AppData\Local\Temp\pip-build-env-n8xytm7x\overlay\Lib\site-packages\setuptools\build_meta.py", line 301, in _get_build_requires
      self.run_setup()
      ~~~~~~~~~~~~~~^^
    File "C:\Users\Kax\AppData\Local\Temp\pip-build-env-n8xytm7x\overlay\Lib\site-packages\setuptools\build_meta.py", line 512, in run_setup
      super().run_setup(setup_script=setup_script)
      ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Kax\AppData\Local\Temp\pip-build-env-n8xytm7x\overlay\Lib\site-packages\setuptools\build_meta.py", line 317, in run_setup
      exec(code, locals())
      ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 128, in <module>
    File "C:\Users\Kax\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 419, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'sentencepiece', '-A', 'x64', '-B', 'build', '-DSPM_ENABLE_SHARED=OFF', '-DCMAKE_INSTALL_PREFIX=build\\root']' returned non-zero exit status 1.
  [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.

If anyone has any suggestions or advice on how to resolve this issue, I would greatly appreciate your help. Thank you!

Kax-Industries avatar Apr 22 '25 22:04 Kax-Industries

It might be a bit late but you can set CMAKE_POLICY_VERSION_MINIMUM=3.5 <Your command> on Linux or on Powershell I believe.

Though the best solution is for the maintainer to fix this.

Neko-Box-Coder avatar May 04 '25 22:05 Neko-Box-Coder

The issue is fixed at HEAD, but there hasn't been a release since then (>1 year).

Ahajha avatar May 09 '25 17:05 Ahajha

I hit this too with Python 3.13, and was able to work around it with a GitHub-centered installation in my pyproject.toml:

dependencies = [
    "sentencepiece @ git+https://github.com/google/sentencepiece.git#subdirectory=python",  # Use GitHub for Python 3.13: https://github.com/google/sentencepiece/issues/1111
]

jamesbraza avatar May 19 '25 21:05 jamesbraza

#1084

imadreamerboy avatar May 22 '25 16:05 imadreamerboy

I'm getting install error even when building with the master, indeed not the CMAKE version error thing, but still seems related to cmake.

     copying src/sentencepiece/_version.py -> build/lib.linux-x86_64-cpython-313/sentencepiece
      copying src/sentencepiece/sentencepiece_model_pb2.py -> build/lib.linux-x86_64-cpython-313/sentencepiece
      copying src/sentencepiece/sentencepiece_pb2.py -> build/lib.linux-x86_64-cpython-313/sentencepiece
      running build_ext
      Package sentencepiece was not found in the pkg-config search path.
      Perhaps you should add the directory containing `sentencepiece.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'sentencepiece' not found
      Traceback (most recent call last):
        File "/home/vladr/fastai/.venv/bin/cmake", line 5, in <module>
          from cmake import cmake
      ModuleNotFoundError: No module named 'cmake'
      Traceback (most recent call last):
        File "/home/vladr/fastai/.venv/bin/cmake", line 5, in <module>
          from cmake import cmake
      ModuleNotFoundError: No module named 'cmake'
      Traceback (most recent call last):
        File "/home/vladr/fastai/.venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
          ~~~~^^
        File "/home/vladr/fastai/.venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/vladr/fastai/.venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
          return _build_backend().build_wheel(
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
              wheel_directory, config_settings, metadata_directory
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          )
          ^
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 435, in build_wheel
          return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)])
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 423, in _build
          return self._build_with_temp_dir(
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^
              cmd,
              ^^^^
          ...<3 lines>...
              self._arbitrary_args(config_settings),
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          )
          ^
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 404, in _build_with_temp_dir
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 512, in run_setup
          super().run_setup(setup_script=setup_script)
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 186, in <module>
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/__init__.py", line 115, in setup
          return distutils.core.setup(**attrs)
                 ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 186, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
          dist.run_commands()
          ~~~~~~~~~~~~~~~~~^^
        File "/tmp/pip-build-env-4azb_vug/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
          self.run_command(cmd)
          ~~~~~~~~~~~~~~~~^^^^^

radnvlad avatar Jun 13 '25 20:06 radnvlad

I am also experiencing this issue when installing a package that depends on it.

lucianchauvin avatar Jun 17 '25 17:06 lucianchauvin

@lucianchauvin What package? I've submitted a couple PRs to some projects to make their support of sentencepiece optional, if it's a case where they only use it if the user uses it potentially the same could be done there.

Ahajha avatar Jun 17 '25 17:06 Ahajha

@Ahajha Anomalib, it may be possible it pops up when running anomalib install -v. I could implement it if you could link to how you did it for other packages.

lucianchauvin avatar Jun 17 '25 17:06 lucianchauvin

@lucianchauvin https://github.com/ggml-org/llama.cpp/pull/14200 https://github.com/mlc-ai/xgrammar/pull/337

Ahajha avatar Jun 17 '25 17:06 Ahajha

@Ahajha Do these break the packages? To me it looks like it these changes just throw an error in the package rather than at the install....

lucianchauvin avatar Jun 17 '25 17:06 lucianchauvin

@Ahajha I got it when I tried installing fastbook

radnvlad avatar Jun 17 '25 17:06 radnvlad

@lucianchauvin For these two cases no. For gguf, it would just throw if you try to use the sentencepiece-specific support without sentencepiece installed (which if you're using it, you probably have it already). Similar for xgrammar, you would only try to use the sentencepiece branches if you already have them installed anyways. In both cases sentencepiece isn't added as a real dependency, but as a "convenience" for those already using it.

Ahajha avatar Jun 17 '25 17:06 Ahajha

@Ahajha Hm okay, I may look into it making a pr for Anomalib tonight if I have some time. Thanks! (python versioning is hell)

lucianchauvin avatar Jun 17 '25 17:06 lucianchauvin

Nice! @radnvlad I'll look at fastbook later - and @lucianchauvin I can help with Anomalib if you'd like.

Ahajha avatar Jun 17 '25 18:06 Ahajha

I glanced at Anomalib, and I'm not quite sure why it's pulling the dependency. It ultimately comes from open-clip-torch, but sentencepiece is only an optional dependency there, it shouldn't be pulling it by default, though I might be misunderstanding how optional dependencies in python work.

Ahajha avatar Jun 17 '25 20:06 Ahajha

fastbook seems to be an annoyingly simple case - they depend on it but don't reference it anywhere, so it should be removable.

Ahajha avatar Jun 17 '25 20:06 Ahajha

@Ahajha yeah I'm not sure about Anomalib. You can get around it with just pip install anomalib[logger].

lucianchauvin avatar Jun 17 '25 21:06 lucianchauvin

Fixed in https://github.com/google/sentencepiece/releases/tag/v0.2.1

taku910 avatar Aug 12 '25 07:08 taku910