gpt4 book ai didi

java - 无法通过 pip 安装 javabridge

转载 作者:太空宇宙 更新时间:2023-11-04 02:20:36 25 4
gpt4 key购买 nike

Ubuntu 18.04, python 2.7

我试试

sudo pip install javabridge

我明白了

      Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-voWMrv/javabridge/setup.py", line 396, in <module>
ext_modules=ext_modules(),
File "/tmp/pip-install-voWMrv/javabridge/setup.py", line 131, in ext_modules
library_dirs = [os.path.dirname(jvm_so)]
File "/usr/lib/python2.7/posixpath.py", line 122, in dirname
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

----------------------------------------

命令“python setup.py egg_info”在/tmp/pip-install-voWMrv/javabridge/中失败,错误代码为 1

我能做到

sudo pip install javabridge==1.0.16

但事实证明我需要最新的,1.0.17,为此我仍然得到上面的错误。

这个命令

find /usr/lib/jvm/java-11-openjdk-amd64 -type f -name "*jvm.so"

给予

/usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so

然后我跑了

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
~$ JDK_HOME=/usr/lib/jvm/java-11-openjdk-amd64

最后

sudo pip install javabridge --user myName

同样的错误

Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-i61jKx/javabridge/setup.py", line 396, in <module>
ext_modules=ext_modules(),
File "/tmp/pip-install-i61jKx/javabridge/setup.py", line 131, in ext_modules
library_dirs = [os.path.dirname(jvm_so)]
File "/usr/lib/python2.7/posixpath.py", line 122, in dirname
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

我也试过

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 JDK_HOME=/usr/lib/jvm/java-11-openjdk-amd64 pip install javabridge --user

Collecting javabridge
Using cached https://files.pythonhosted.org/packages/68/87/0b016838c2a33b46b8775a3890150c93507931127cf62e9ccf27ac20db34/javabridge-1.0.17.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-QDCLar/javabridge/setup.py", line 396, in <module>
ext_modules=ext_modules(),
File "/tmp/pip-install-QDCLar/javabridge/setup.py", line 131, in ext_modules
library_dirs = [os.path.dirname(jvm_so)]
File "/usr/lib/python2.7/posixpath.py", line 122, in dirname
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

最佳答案

看起来您遇到了 this issue . javabridge 包未更新到 Java 9/10/11 中关于重组 JRE 目标目录(以删除的目标 arch 命名的中间目录)的更改,因此您只能使用 Java 8此时此刻。这就是我如何在 ubuntu:latest docker 容器中成功安装 javabridge:

$ apt update
$ apt install software-properties-common
$ add-apt-repository ppa:webupd8team/java
$ apt install openjdk-8-jdk
$ update-alternatives --config java

这应该为您提供类似于 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 的 OpenJDK 8 路径,删除 jre/bin/java 后缀获取 JDK 根。

现在安装javabridge:

$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 pip install javabridge --user
Installing collected packages: javabridge
Running setup.py install for javabridge ... done
Successfully installed javabridge-1.0.17

关于java - 无法通过 pip 安装 javabridge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51756910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com