无法点安装javabridge

时间:2018-08-08 23:18:09

标签: java python pip

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'

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

/ tmp / pip-install-voWMrv / javabridge /

中的命令“ python setup.py egg_info”失败,错误代码为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'

2 个答案:

答案 0 :(得分:2)

您似乎遇到了this issuejavabridge软件包未更新为Java 9/10/11中有关JRE目标目录(以除去目标拱门而命名的中间目录)的重组的更改,因此您目前只能使用Java 8。这是我可以在javabridge Docker容器中成功安装ubuntu:latest的方式:

$ 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

答案 1 :(得分:0)

https://pythonhosted.org/javabridge/installation.html#dependencies

Javabridge需要Python 2.6或更高版本,NumPy,Java开发工具包(JDK)和C编译器。

sudo apt install python2.7 python-numpy openjdk-8-jdk gcc