1

为了在 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
4

1 回答 1

0

好吧,基于错误,我认为在 Windows 操作系统中编译 Jnius 扩展所需的 Python 软件包缺少部分存在问题,老实说,在 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

于 2020-09-16T01:34:24.437 回答