Python与Java,PyJNIus安装

时间:2016-02-14 17:09:53

标签: java python pyjnius

为了在Python中使用Java绑定,我正在安装,以下内容: https://github.com/kivy/pyjnius

我收到了这个错误:它似乎试图将C ++文件头编译到Java_HOME ....,这看起来很奇怪:

    Installing collected packages: jnius
      Running setup.py install for jnius
        Complete output from command D:\_devs\Python01\WinPython-64-2710\python-2.7.10.amd64\python.exe -c "import setuptools, tokenize;__file__='f:\\usertemp\\pip-build-wdmlwj\\jnius\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record f:\usertemp\pip-f_a0kd-record\install-record.txt --single-version-externally-managed --compile:
        running install
        running build
        running build_py
        running build_ext
        skipping 'jnius\jnius.c' Cython extension (up-to-date)
        building 'jnius' extension
        D:\_devs\Python01\WinPython-64-2710\python-2.7.10.amd64\Scripts\gcc.exe -mdll -O -Wall -IE:\_devs\JDK7\include -IE:\_devs\JDK7\include\linux -ID:\_devs\Python01\WinPython-64-2710\python-2.7.10.amd64\include -ID:\_devs\Python01\WinPython-64-2710\python-2.7.10.amd64\PC -c jnius\jnius.c -o build\temp.win-amd64-2.7\Release\jnius\jnius.o
        In file included from jnius\jnius.c:256:0:
        E:\_devs\JDK7\include/jni.h:45:20: fatal error: jni_md.h: No such file or directory
         #include "jni_md.h"
                            ^
        compilation terminated.
        error: command 'D:\\_devs\\Python01\\WinPython-64-2710\\python-2.7.10.amd64\\Scripts\\gcc.exe' failed with exit status 1

1 个答案:

答案 0 :(得分:0)

基于错误,我认为Python缺少在Windows OS中编译Jnius扩展所需的软件包的某些部分的问题,说实话,在Windows中您会发现比Ubuntu出错更多的错误,我不知道为什么,我从Windows切换到Ubuntu,现在,编程变得更好又简单,但这是一种解决方法:

在Ubuntu中,我知道执行此操作的命令,但是对于Windows,请在此处查看: https://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/

在这里: https://solarianprogrammer.com/2019/11/05/install-gcc-windows/

我能给您的最好建议是,安装最新的稳定版Ubuntu官方软件,无需卸载Windows,您可以同时拥有Ubuntu和Windows