当前位置:   article > 正文

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

sentencepiece调用_sentencepiece报错

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.
----------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

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
  • 1
  • 2
  • 3
  • 4
  • 5
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 ~]#

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/466923
推荐阅读
相关标签
  

闽ICP备14008679号