【实例】解决pip install jpype1 失败问题,手动安装

C:\Users\d>pip install E:\JPype1-0.6.2-cp36-cp36m-win_amd64.whl
Processing e:\jpype1-0.6.2-cp36-cp36m-win_amd64.whl
Installing collected packages: JPype1

Successfully installed JPype1-0.6.2

安装包地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype

#C:\Users\d>pip install jpype1

Collecting jpype1
  Using cached JPype1-0.6.2.tar.gz
Building wheels for collected packages: jpype1
  Running setup.py bdist_wheel for jpype1 ... error
  Complete output from command c:\users\oil\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\oil\\AppData\\Local\\Temp\\pip-build-arnumae5\\jpype1\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\oil\AppData\Local\Temp\tmpe1u001j4pip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\jpype
  copying jpype\JClassUtil.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\nio.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\reflect.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_core.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_darwin.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_gui.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jarray.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jclass.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jcollection.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jexception.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jobject.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jpackage.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jproxy.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jvmfinder.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_jwrapper.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_linux.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_properties.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_pykeywords.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_refdaemon.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\_windows.py -> build\lib.win-amd64-3.6\jpype
  copying jpype\__init__.py -> build\lib.win-amd64-3.6\jpype
  creating build\lib.win-amd64-3.6\jpype\awt
  copying jpype\awt\__init__.py -> build\lib.win-amd64-3.6\jpype\awt
  creating build\lib.win-amd64-3.6\jpype\awt\event
  copying jpype\awt\event\WindowAdapter.py -> build\lib.win-amd64-3.6\jpype\awt\event
  copying jpype\awt\event\__init__.py -> build\lib.win-amd64-3.6\jpype\awt\event
  creating build\lib.win-amd64-3.6\jpypex
  copying jpypex\__init__.py -> build\lib.win-amd64-3.6\jpypex
  creating build\lib.win-amd64-3.6\jpypex\swing
  copying jpypex\swing\AbstractAction.py -> build\lib.win-amd64-3.6\jpypex\swing
  copying jpypex\swing\pyutils.py -> build\lib.win-amd64-3.6\jpypex\swing
  copying jpypex\swing\__init__.py -> build\lib.win-amd64-3.6\jpypex\swing
  running build_ext
  C:\Users\oil\AppData\Local\Temp\pip-build-arnumae5\jpype1\setup.py:164: FeatureNotice: Turned ON Numpy support for fast Java array access
    FeatureNotice)
  building '_jpype' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools


测试:

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import jpype
>>>
>>> jvmPath = jpype.getDefaultJVMPath()       # 默认的JVM路径
>>> print(jvmPath)
C:\Program Files\Java\jdk1.8.0_131\jre\bin\server\jvm.dll
>>> jpype.startJVM(jvmPath)
>>> jpype.java.lang.System.out.println("hello world!")
hello world!
>>> jpype.java.lang.System.out.println("I hate you!")
I hate you!
>>>
>>> jpype.shutdownJVM()
JVM activity report     :
        classes loaded       : 31
JVM has been shutdown
>>>

你可能感兴趣的:(python,jpype)