无法点安装javabridge [英] Can't pip install javabridge
问题描述
Ubuntu 18.04,Python 2.7
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/
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-voWMrv/javabridge/
我能够做到
sudo pip install javabridge==1.0.16
但是事实证明,我需要最新的版本1.0.17,为此我仍然会遇到上述错误.
But it turns out that I need the newest one, 1.0.17, for which I still get the error above.
此命令
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'
推荐答案
It looks like you're running into this issue. javabridge
package is not updated to changes in Java 9/10/11 regarding the restructuring of the JRE target dir (an intermediate dir named after the target arch removed), so you can only use the Java 8 at the moment. This is how I could install javabridge
successfully in an ubuntu:latest
docker container:
$ 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根.
This should give you the path to OpenJDK 8 similar to /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
, remove the jre/bin/java
suffix to get the JDK root.
现在安装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
这篇关于无法点安装javabridge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!