我在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的问题?
答案 0 :(得分:2)
请原谅不那么完整的答案,但这与Python2和Python3之间的字符串差异有关。使用Python2.7至少可以帮助您解决问题。 See this post了解更多背景信息。