Search code examples
pythonpipsentencepiece

Getting requirements to build wheel did not run successfully


Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS D:\Translator> pip install sentencepiece
Collecting sentencepiece
  Using cached sentencepiece-0.1.99.tar.gz (2.6 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      -- Building for: NMake Makefiles
      CMake Deprecation Warning at CMakeLists.txt:15 (cmake_minimum_required):
        Compatibility with CMake < 3.5 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.


      -- VERSION: 0.1.99
      CMake Error at CMakeLists.txt:23 (project):
        Generator

          NMake Makefiles

        does not support platform specification, but platform

          x64

        was specified.


      CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
      CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
      -- Configuring incomplete, errors occurred!
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\HP\AppData\Local\Temp\pip-install-dpmwkzpa\sentencepiece_9e719dbab29d416994c7337531af3dca\setup.py", line 126, in <module>
          subprocess.check_call([
        File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 413, 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: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
PS D:\Translator>

Solution

  • This seems to be a common problem with installing this package as can be seen on https://github.com/google/sentencepiece/issues/591.

    One way to fix this is to build and install the Python wrapper from source, try the following commands to build and install wheel package:

    % git clone https://github.com/google/sentencepiece.git 
    % cd sentencepiece
    % mkdir build
    % cd build
    % cmake .. -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=./root
    % make install
    % cd ../python
    % python setup.py bdist_wheel
    % pip install dist/sentencepiece*.whl
    

    If this doesn't work, you can try to manually download the file for your platform. Be sure to choose the right file for your platform.

    If none of these works, you may have to consider downgrading your python version to 3.10.