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'

最佳答案

您好像遇到了this issuejavabridge软件包未更新为Java 9/10/11中有关JRE目标目录(以删除目标拱门命名的中间目录)的重组的更改,因此您目前只能使用Java 8。这是我如何在javabridge泊坞窗容器中成功安装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

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

10-09 12:38