python3使用pip安装sentencepiece出现returned non-zero exit status 127.

发布时间:2024年01月04日

python3使用pip安装sentencepiece出现returned non-zero exit status 127.

出现错误类似如下:

[root@bb4d85446731 ~]# pip38 install sentencepiece0.1.97 -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting sentencepiece
0.1.97
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/87/f26695307c0aa00e6938f5de795fc7f2c718a448b48d29a4c8c8dbf829d3/sentencepiece-0.1.97.tar.gz (524kB)
|████████████████████████████████| 532kB 837kB/s
Installing collected packages: sentencepiece
Running setup.py install for sentencepiece … error
ERROR: Command errored out with exit status 1:
command: /usr/local/python3/bin/python3.8 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-d_7bw4tg/sentencepiece/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-d_7bw4tg/sentencepiece/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-9q4o7si8/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-d_7bw4tg/sentencepiece/
Complete output (74 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/init.py -> build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/_version.py -> build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/sentencepiece_model_pb2.py -> build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/sentencepiece_pb2.py -> build/lib.linux-x86_64-3.8/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’, required by ‘virtual:world’, not found
Cloning into ‘sentencepiece’…
Note: switching to ‘58f256cf6f01bb86e6fa634a5cc560de5bd1667d’.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

./build_bundled.sh: line 19: cmake: command not found
./build_bundled.sh: line 20: cmake: command not found
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-d_7bw4tg/sentencepiece/setup.py", line 136, in <module>
    setup(
  File "/usr/local/python3/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/python3/lib/python3.8/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/python3/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/python3/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/python3/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
    return orig.install.run(self)
  File "/usr/local/python3/lib/python3.8/distutils/command/install.py", line 545, in run
    self.run_command('build')
  File "/usr/local/python3/lib/python3.8/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/python3/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/python3/lib/python3.8/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/usr/local/python3/lib/python3.8/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/python3/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/python3/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 84, in run
    _build_ext.run(self)
  File "/usr/local/python3/lib/python3.8/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/usr/local/python3/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
    self._build_extensions_serial()
  File "/usr/local/python3/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
    self.build_extension(ext)
  File "/tmp/pip-install-d_7bw4tg/sentencepiece/setup.py", line 89, in build_extension
    subprocess.check_call(['./build_bundled.sh', __version__])
  File "/usr/local/python3/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['./build_bundled.sh', '0.1.97']' returned non-zero exit status 127.
----------------------------------------

ERROR: Command errored out with exit status 1: /usr/local/python3/bin/python3.8 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-d_7bw4tg/sentencepiece/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-d_7bw4tg/sentencepiece/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-9q4o7si8/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 23.3.2 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.


[root@bb4d85446731 ~]# pip38 install sentencepiece -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting sentencepiece
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d8/87/b37ebc960d0a85e10785a1a92d796edbd975840bee150a9ae3ba5d7a0250/sentencepiece-0.1.99.tar.gz (2.6MB)
|████████████████████████████████| 2.6MB 1.4MB/s
Installing collected packages: sentencepiece
Running setup.py install for sentencepiece … error
ERROR: Command errored out with exit status 1:
command: /usr/local/python3/bin/python3.8 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-1groyzvx/sentencepiece/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-1groyzvx/sentencepiece/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’“‘))’ install --record /tmp/pip-record-twlylh7d/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-1groyzvx/sentencepiece/
Complete output (56 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/init.py -> build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/_version.py -> build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/sentencepiece_model_pb2.py -> build/lib.linux-x86_64-3.8/sentencepiece
copying src/sentencepiece/sentencepiece_pb2.py -> build/lib.linux-x86_64-3.8/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’, required by ‘virtual:world’, not found
./build_bundled.sh: line 21: cmake: command not found
./build_bundled.sh: line 22: cmake: command not found
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-1groyzvx/sentencepiece/setup.py”, line 167, in
setup(
File “/usr/local/python3/lib/python3.8/site-packages/setuptools/init.py”, line 145, in setup
return distutils.core.setup(**attrs)
File “/usr/local/python3/lib/python3.8/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/local/python3/lib/python3.8/distutils/dist.py”, line 966, in run_commands
self.run_command(cmd)
File “/usr/local/python3/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/local/python3/lib/python3.8/site-packages/setuptools/command/install.py”, line 61, in run
return orig.install.run(self)
File “/usr/local/python3/lib/python3.8/distutils/command/install.py”, line 545, in run
self.run_command(‘build’)
File “/usr/local/python3/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/local/python3/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/local/python3/lib/python3.8/distutils/command/build.py”, line 135, in run
self.run_command(cmd_name)
File “/usr/local/python3/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/local/python3/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/local/python3/lib/python3.8/site-packages/setuptools/command/build_ext.py”, line 84, in run
_build_ext.run(self)
File “/usr/local/python3/lib/python3.8/distutils/command/build_ext.py”, line 340, in run
self.build_extensions()
File “/usr/local/python3/lib/python3.8/distutils/command/build_ext.py”, line 449, in build_extensions
self._build_extensions_serial()
File “/usr/local/python3/lib/python3.8/distutils/command/build_ext.py”, line 474, in _build_extensions_serial
self.build_extension(ext)
File “/tmp/pip-install-1groyzvx/sentencepiece/setup.py”, line 87, in build_extension
subprocess.check_call([‘./build_bundled.sh’, version])
File “/usr/local/python3/lib/python3.8/subprocess.py”, line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’./build_bundled.sh’, ‘0.1.99’]’ returned non-zero exit status 127.
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/python3/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '”‘"’/tmp/pip-install-1groyzvx/sentencepiece/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-1groyzvx/sentencepiece/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /tmp/pip-record-twlylh7d/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 23.3.2 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
[root@bb4d85446731 ~]#



解决方法:
1)源码编译:

 yum install cmake make gcc gcc-c++ -y
 git clone https://github.com/google/sentencepiece.git 
 cd sentencepiece
 mkdir build
 cd build
 cmake ..
 make -j $(nproc)
 sudo make install
 sudo ldconfig -v

2)下载依赖库安装:

wget https://files.pythonhosted.org/packages/c9/58/4fbd3f33a38c9809fedf57bbef7e086b9909d6807148f35d68c0c90896d3/sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

mv sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_x86_64.linux_x86_64.whl

pip38 install sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_x86_64.linux_x86_64.whl
Processing ./sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_x86_64.linux_x86_64.whl
Installing collected packages: sentencepiece
Successfully installed sentencepiece-0.1.99
WARNING: You are using pip version 19.2.3, however version 23.3.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@bb4d85446731 ~]#

文章来源:https://blog.csdn.net/u014374009/article/details/135377972
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。