使用javabridge和python的麻烦



我在Mac的虚拟环境上使用$pip3 install javabridge成功安装了Javabridge。但是,当我尝试在Python3代码中导入Javabridge时,这就是我得到的:

import javabridge
Failed to run /usr/libexec/java_home, defaulting to best guess for Java
Traceback (most recent call last):
  File "/Users/puifai/Documents/data_science/venv/venv3/lib/python3.6/site-packages/javabridge/locate.py", line 45, in find_javahome
    os.path.join(os.path.dirname(path), "Libraries"),
  File "/Users/puifai/Documents/data_science/venv/venv3/bin/../lib/python3.6/posixpath.py", line 92, in join
    genericpath._check_arg_types('join', a, *p)
  File "/Users/puifai/Documents/data_science/venv/venv3/bin/../lib/python3.6/genericpath.py", line 151, in _check_arg_types
    raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components

关于如何解决此问题的任何想法?它看起来像是Python而不是Javabridge的问题?

赦免不太完整的答案,但这与python2和python3之间的字符串差异有关。在Python2.7中工作至少将使您暂时解决问题。有关更多背景,请参见这篇文章。

最新更新