安装pyhanlp遇到报错,不会解决了

在安装pyhanlp时遇到问题,网上查不到结果了,请教各位大佬能帮忙解决下吗?本人python是3.9.6,安装了jpype1 可是还是报错

安装报错
代码如下
C:\Users\Administrator>conda install -c conda-forge jpype1
Collecting package metadata (current_repodata.json): done
Solving environment: done

All requested packages already installed.

C:\Users\Administrator>pip install pyhanlp
Collecting pyhanlp
Using cached pyhanlp-0.1.79-py3-none-any.whl
Collecting jpype1==0.7.0
Using cached JPype1-0.7.0.tar.gz (470 kB)
Preparing metadata (setup.py) … done
Requirement already satisfied: hanlp-downloader in c:\programdata\anaconda3\lib\site-packages (from pyhanlp) (0.0.25)
Requirement already satisfied: requests in c:\programdata\anaconda3\lib\site-packages (from hanlp-downloader->pyhanlp) (2.26.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests->hanlp-downloader->pyhanlp) (2021.10.8)
Requirement already satisfied: idna<4,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests->hanlp-downloader->pyhanlp) (3.2)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests->hanlp-downloader->pyhanlp) (1.26.6)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\programdata\anaconda3\lib\site-packages (from requests->hanlp-downloader->pyhanlp) (2.0.4)
Building wheels for collected packages: jpype1
Building wheel for jpype1 (setup.py) … error
ERROR: Command errored out with exit status 1:
command: ‘C:\ProgramData\Anaconda3\python.exe’ -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setup.py’"’"’; file=’"’"‘C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d ‘C:\Users\Administrator\AppData\Local\Temp\pip-wheel-1m0uk80g’
cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9
Complete output (54 lines):
C:\ProgramData\Anaconda3\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: ‘use_scm_version’
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\jpype
copying jpype\beans.py -> build\lib.win-amd64-3.8\jpype
copying jpype\imports.py -> build\lib.win-amd64-3.8\jpype
copying jpype\nio.py -> build\lib.win-amd64-3.8\jpype
copying jpype\reflect.py -> build\lib.win-amd64-3.8\jpype
copying jpype\types.py -> build\lib.win-amd64-3.8\jpype
copying jpype_classpath.py -> build\lib.win-amd64-3.8\jpype
copying jpype_core.py -> build\lib.win-amd64-3.8\jpype
copying jpype_cygwin.py -> build\lib.win-amd64-3.8\jpype
copying jpype_darwin.py -> build\lib.win-amd64-3.8\jpype
copying jpype_gui.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jarray.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jboxed.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jclass.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jcollection.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jcomparable.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jcustomizer.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jexception.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jinit.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jio.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jobject.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jpackage.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jproxy.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jstring.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jtypes.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jvmfinder.py -> build\lib.win-amd64-3.8\jpype
copying jpype_linux.py -> build\lib.win-amd64-3.8\jpype
copying jpype_pykeywords.py -> build\lib.win-amd64-3.8\jpype
copying jpype_windows.py -> build\lib.win-amd64-3.8\jpype
copying jpype_init_.py -> build\lib.win-amd64-3.8\jpype
running build_ext
running build_java
Using Jar cache
creating build\lib
creating build\lib\org
creating build\lib\org\jpype
creating build\lib\org\jpype\classloader
copying native\jars\org\jpype\classloader\JPypeClassLoader.class -> build\lib\org\jpype\classloader
copying native\jars\org.jpype.jar -> build\lib
running build_thunk
Building thunks
C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setupext\build_ext.py:84: FeatureNotice: Turned ON Numpy support for fast Java array access
warnings.warn(“Turned ON Numpy support for fast Java array access”,
including thunk build\lib\org\jpype\classloader\JPypeClassLoader.class
including thunk build\lib\org.jpype.jar
building ‘_jpype’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/

ERROR: Failed building wheel for jpype1
Running setup.py clean for jpype1
Failed to build jpype1
Installing collected packages: jpype1, pyhanlp
Attempting uninstall: jpype1
Found existing installation: jpype1 1.3.0
Uninstalling jpype1-1.3.0:
Successfully uninstalled jpype1-1.3.0
Running setup.py install for jpype1 … error
ERROR: Command errored out with exit status 1:
command: ‘C:\ProgramData\Anaconda3\python.exe’ -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setup.py’"’"’; file=’"’"‘C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\Administrator\AppData\Local\Temp\pip-record-uemq7hly\install-record.txt’ --single-version-externally-managed --compile --install-headers ‘C:\ProgramData\Anaconda3\Include\jpype1’
cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9
Complete output (48 lines):
C:\ProgramData\Anaconda3\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: ‘use_scm_version’
warnings.warn(msg)
running install
running build
running build_py
creating build\lib.win-amd64-3.8
creating build\lib.win-amd64-3.8\jpype
copying jpype\beans.py -> build\lib.win-amd64-3.8\jpype
copying jpype\imports.py -> build\lib.win-amd64-3.8\jpype
copying jpype\nio.py -> build\lib.win-amd64-3.8\jpype
copying jpype\reflect.py -> build\lib.win-amd64-3.8\jpype
copying jpype\types.py -> build\lib.win-amd64-3.8\jpype
copying jpype_classpath.py -> build\lib.win-amd64-3.8\jpype
copying jpype_core.py -> build\lib.win-amd64-3.8\jpype
copying jpype_cygwin.py -> build\lib.win-amd64-3.8\jpype
copying jpype_darwin.py -> build\lib.win-amd64-3.8\jpype
copying jpype_gui.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jarray.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jboxed.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jclass.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jcollection.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jcomparable.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jcustomizer.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jexception.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jinit.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jio.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jobject.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jpackage.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jproxy.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jstring.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jtypes.py -> build\lib.win-amd64-3.8\jpype
copying jpype_jvmfinder.py -> build\lib.win-amd64-3.8\jpype
copying jpype_linux.py -> build\lib.win-amd64-3.8\jpype
copying jpype_pykeywords.py -> build\lib.win-amd64-3.8\jpype
copying jpype_windows.py -> build\lib.win-amd64-3.8\jpype
copying jpype_init_.py -> build\lib.win-amd64-3.8\jpype
running build_ext
running build_java
Using Jar cache
copying native\jars\org\jpype\classloader\JPypeClassLoader.class -> build\lib\org\jpype\classloader
copying native\jars\org.jpype.jar -> build\lib
running build_thunk
Building thunks
Skip build thunks
C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setupext\build_ext.py:84: FeatureNotice: Turned ON Numpy support for fast Java array access
warnings.warn(“Turned ON Numpy support for fast Java array access”,
building ‘_jpype’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
Rolling back uninstall of jpype1
Moving to c:\programdata\anaconda3\lib\site-packages_jpype.cp38-win_amd64.pyd
from C:\Users\Administrator\AppData\Local\Temp\pip-uninstall-t51jitrx_jpype.cp38-win_amd64.pyd
Moving to c:\programdata\anaconda3\lib\site-packages\jpype1-1.3.0.dist-info
from C:\ProgramData\Anaconda3\Lib\site-packages~pype1-1.3.0.dist-info
Moving to c:\programdata\anaconda3\lib\site-packages\jpype
from C:\ProgramData\Anaconda3\Lib\site-packages~pype
Moving to c:\programdata\anaconda3\lib\site-packages\org.jpype.jar
from C:\Users\Administrator\AppData\Local\Temp\pip-uninstall-t51jitrx\org.jpype.jar
ERROR: Command errored out with exit status 1: ‘C:\ProgramData\Anaconda3\python.exe’ -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setup.py’"’"’; file=’"’"‘C:\Users\Administrator\AppData\Local\Temp\pip-install-hdvxs84u\jpype1_31f827af2df442eb97ce2115f14b38c9\setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\Administrator\AppData\Local\Temp\pip-record-uemq7hly\install-record.txt’ --single-version-externally-managed --compile --install-headers ‘C:\ProgramData\Anaconda3\Include\jpype1’ Check the logs for full command output.

  1. 一键安装:
conda install -c conda-forge openjdk python=3.8 jpype1=0.7.0 -y
pip install pyhanlp
  1. 视频和傻瓜虚拟机:

随着拙作的流行,一些没有编程基础的读者也开始阅读《自然语言处理入门》。若遇到安装运行问题,请按照教程视频一步步来,实在没能力的请直接使用傻瓜虚拟机

感谢及时回复。
问题已经解决。
解决方法:
1.安装Visual Studio 2022 Current。C++桌面开发工具包和Python开发工具包必选
2.pip install pyhanlp

1 Like