1

我正在使用 Anaconda Python 并使用以下内容安装 jpype:

conda install -c conda-forge jpype1

我安装了 GCC:

Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

我在安装过程中没有收到任何错误。

conda install -c conda-forge jpype1 
Collecting package metadata: done
Solving environment: done

# All requested packages already installed.

如果我运行,pip search jpype我将得到以下信息:

jtypes.jpype (0.6.3b3)  - A Python to Java bridge (ctypes/cffi-based JPype).
JPype1-py3 (0.5.5.2)    - Python-Java bridge. Fork of the jPype project by Steve Menard (http://jpype.sourceforge.net/), with the modifications applied by Luis Nell
                          (https://github.com/originell/jpype)

但仍然无法调用图书馆

>>> import jpype
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'jpype'
4

2 回答 2

4

这可能是因为它是作为 Python 2 包安装的,而您正在运行 Python 3 或相反。

要专门为 Python 3 安装包,请尝试输入以下命令:

pip3 install jpype1

或者

python3 -m pip install jpype1

要专门为 Python 2 安装包,请尝试输入以下命令:

pip2 install jpype1

或者

python -m pip install jpype1
于 2019-04-03T21:28:28.080 回答
1

我发现了问题。错误地,我有导致问题的 Anaconda 3.6 和 3.7 的两个版本。

于 2019-04-03T22:50:09.877 回答