from pycorrector import Corrector
m = Corrector()
m.correct('你好')
Traceback (most recent call last):
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/detector.py", line 96, in _initialize_detector
import kenlm
ModuleNotFoundError: No module named 'kenlm'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/corrector.py", line 288, in correct
maybe_errors, proper_details = self._detect(sent, idx, **kwargs)
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/detector.py", line 397, in _detect
self.check_detector_initialized()
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/detector.py", line 151, in check_detector_initialized
self._initialize_detector()
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/detector.py", line 98, in _initialize_detector
raise ImportError(
ImportError: pycorrector dependencies are not fully installed, they are required for statistical language model.Please use "pip install kenlm" to install it.if you are Win, Please install kenlm in cgwin.
然后 pip insatll kenlm 报错
pip insatll kenlm
Defaulting to user installation because normal site-packages is not writeable
Collecting kenlm
Using cached kenlm-0.2.0.tar.gz (427 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: kenlm
Building wheel for kenlm (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /data/anaconda3/envs/baojia/bin/python /data/anaconda3/envs/baojia/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpmrtapn
cwd: /tmp/pip-install-08gfu_f4/kenlm_1a8af565ef004386bf63337a72d07f6f
Complete output (76 lines):
Will build with KenLM max_order set to 6
running bdist_wheel
running build
running build_ext
CMake Deprecation Warning at CMakeLists.txt:1 (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.
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:14 (project):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
File "/data/anaconda3/envs/baojia/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in
main()
File "/data/anaconda3/envs/baojia/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
json_out['return_val'] = hook(hook_input['kwargs'])
File "/data/anaconda3/envs/baojia/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 248, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 420, in build_wheel
return self._build_with_temp_dir(
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 402, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 502, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 318, in run_setup
exec(code, locals())
File "", line 124, in
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/init.py", line 111, in setup
return distutils.core.setup(attrs)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 184, in setup
return run_commands(dist)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
dist.run_commands()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 964, in run_commands
self.run_command(cmd)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 948, in run_command
super().run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 983, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/command/bdist_wheel.py", line 384, in run
self.run_command("build")
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 948, in run_command
super().run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 983, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 948, in run_command
super().run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 983, in run_command
cmd_obj.run()
File "", line 104, in run
File "/data/anaconda3/envs/baojia/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-08gfu_f4/kenlm_1a8af565ef004386bf63337a72d07f6f', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-08gfu_f4/kenlm_1a8af565ef004386bf63337a72d07f6f/build/lib.linux-x86_64-cpython-39', '-DBUILD_SHARED_LIBS=ON', '-DBUILD_PYTHON_STANDALONE=ON', '-DKENLM_MAX_ORDER=6', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
ERROR: Failed building wheel for kenlm
Failed to build kenlm
ERROR: Could not build wheels for kenlm which use PEP 517 and cannot be installed directly
pip install pycorrector后运行报错:
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "", line 1, in
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/corrector.py", line 288, in correct
maybe_errors, proper_details = self._detect(sent, idx, **kwargs)
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/detector.py", line 397, in _detect
self.check_detector_initialized()
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/detector.py", line 151, in check_detector_initialized
self._initialize_detector()
File "/home/izhaowo/.local/lib/python3.9/site-packages/pycorrector/detector.py", line 98, in _initialize_detector
raise ImportError(
ImportError: pycorrector dependencies are not fully installed, they are required for statistical language model.Please use "pip install kenlm" to install it.if you are Win, Please install kenlm in cgwin.
然后 pip insatll kenlm 报错
-- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is unknown -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done CMake Error at CMakeLists.txt:14 (project): No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred! Traceback (most recent call last): File "/data/anaconda3/envs/baojia/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in
main()
File "/data/anaconda3/envs/baojia/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
json_out['return_val'] = hook(hook_input['kwargs'])
File "/data/anaconda3/envs/baojia/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 248, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 420, in build_wheel
return self._build_with_temp_dir(
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 402, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 502, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 318, in run_setup
exec(code, locals())
File "", line 124, in
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/init.py", line 111, in setup
return distutils.core.setup( attrs)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 184, in setup
return run_commands(dist)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
dist.run_commands()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 964, in run_commands
self.run_command(cmd)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 948, in run_command
super().run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 983, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/command/bdist_wheel.py", line 384, in run
self.run_command("build")
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 948, in run_command
super().run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 983, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 948, in run_command
super().run_command(command)
File "/tmp/pip-build-env-iq86k7ro/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 983, in run_command
cmd_obj.run()
File "", line 104, in run
File "/data/anaconda3/envs/baojia/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-08gfu_f4/kenlm_1a8af565ef004386bf63337a72d07f6f', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-08gfu_f4/kenlm_1a8af565ef004386bf63337a72d07f6f/build/lib.linux-x86_64-cpython-39', '-DBUILD_SHARED_LIBS=ON', '-DBUILD_PYTHON_STANDALONE=ON', '-DKENLM_MAX_ORDER=6', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
ERROR: Failed building wheel for kenlm Failed to build kenlm ERROR: Could not build wheels for kenlm which use PEP 517 and cannot be installed directly