代碼:
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()