代码:
virtualenv test
cd Script
activate
pip install jpype1

由于是新系统,会报错,所以需要修改源码需要先卸载
解决办法:1,不用jpype;2,修改源码(已经有人修改好)
第一步:
D:\pythonworkspace>pip uninstall Jpype1
Uninstalling JPype1-0.6.3:
Would remove:
c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\_jpype.cp37-win_amd64.pyd
c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\jpype1-0.6.3.dist-info\*
c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\jpype\*
c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\jpypex\*
Proceed (y/n)? y
Successfully uninstalled JPype1-0.6.3
D:\pythonworkspace>
第二步,下载:
第三步,安装
pip install JPype1-0.6.3-cp37-cp37m-win_amd64.whl
pip install numpy_quaternion-2018.8.13-cp37-cp37m-win_amd64.whl
第四步:新建项目,选择虚拟环境(上文提到的test环境)中的python
运行如下代码:
import jpype jvmPath = jpype.getDefaultJVMPath() jpype.startJVM(jvmPath) jpype.java.lang.System.out.println("hello Hanlp!") jpype.shutdownJVM()