Java 如何在ubuntu 20.04上构建和安装pylucene
我正在尝试在我的WSL Ubuntu 20.04清洁安装上安装Pylucene。我试着继续学习教程。所以我想知道这里是否有人能让它在Ubuntu 20.04和python 3.8.2上工作 我运行的命令:Java 如何在ubuntu 20.04上构建和安装pylucene,java,python,pylucene,Java,Python,Pylucene,我正在尝试在我的WSL Ubuntu 20.04清洁安装上安装Pylucene。我试着继续学习教程。所以我想知道这里是否有人能让它在Ubuntu 20.04和python 3.8.2上工作 我运行的命令: sudo apt-get upgrade sudo apt-get install -y default-jdk ant build-essential python3-dev mkdir pylucene cd pylucene curl https://downloads.apache.o
sudo apt-get upgrade
sudo apt-get install -y default-jdk ant build-essential python3-dev
mkdir pylucene
cd pylucene
curl https://downloads.apache.org/lucene/pylucene/pylucene-8.3.0-src.tar.gz | tar -xz --strip-components=1
cd jcc
export JCC_JDK=/usr/lib/jvm/default-java
python3 setup.py build
^^^^^
在以下位置失败:
...
building 'jcc3' extension
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_jcc_lib -DJCC_VER="3.7" -I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux -I_jcc3 -Ijcc3/sources -I/usr/include/python3.8 -c jcc3/sources/jcc.cpp -o build/temp.linux-x86_64-3.8/jcc3/sources/jcc.o -DPYTHON -fno-strict-aliasing -Wno-write-strings
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_jcc_lib -DJCC_VER="3.7" -I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux -I_jcc3 -Ijcc3/sources -I/usr/include/python3.8 -c jcc3/sources/JCCEnv.cpp -o build/temp.linux-x86_64-3.8/jcc3/sources/JCCEnv.o -DPYTHON -fno-strict-aliasing -Wno-write-strings
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.8/jcc3/sources/jcc.o build/temp.linux-x86_64-3.8/jcc3/sources/JCCEnv.o -o build/lib.linux-x86_64-3.8/libjcc3.so -L/usr/lib/jvm/default-java/jre/lib/amd64 -ljava -L/usr/lib/jvm/default-java/jre/lib/amd64/server -ljvm -Wl,-rpath=/usr/lib/jvm/default-java/jre/lib/amd64:/usr/lib/jvm/default-java/jre/lib/amd64/server -Wl,-S
/usr/bin/ld: cannot find -ljava
/usr/bin/ld: cannot find -ljvm
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
我计划以后运行的命令:
sudo python3 --preserve-env=JCC_JDK setup.py install
cd ..
make
make test
sudo make install
以下是在Ubuntu 18.04上成功安装pylucene的步骤-这可能对您有用:
apt安装openjdk-8-jre-openjdk-8-jdk-openjdk-8-doc
如果未运行apt install ant
,请确保已安装ant。请注意,如果安装了不同版本的openjdk,则需要将其删除或运行updatealternations
,以便使用1.8.0版
Java-version
sudo apt安装python开发工具
在我的例子中,Python 3不起作用,所以我最终使用了Python 2。但这可能不是问题的真正原因,因此欢迎您尝试Python3。如果使用Python 3,请在下面的命令中使用python3
而不是Python
make
make test
sudo make install
--shared
确认@code your dream发布的答案也适用于Python3(特别是在Ubuntu 18.04.1中) 对我来说,以这种方式安装jcc很重要。我尝试通过conda安装,但pylucene的制造存在冲突 在我的例子中,还需要修改jcc中的setup.py文件 “linux”:['-fno严格别名','-Wno写入字符串'], 通过 “linux”:['-fno严格别名','-Wno写入字符串','-D_ustdc_格式_宏'], 正如在另一个线程中提到的 要确认所需的java版本(在我的例子中也是8,与11不兼容),可以在pylucene文件夹/jcc/setup.py中搜索块JDK={…}。就我而言,参考:
“linux”:“/usr/lib/jvm/java-8-oracle”,您是否检查了
libjava.so
和libjvm.so
是否存在于-L
选项中提到的任何路径或您系统中的任何其他位置?我不知道该如何操作tbh。我建议进入/usr/lib/jvm
文件夹并执行搜索,看看您是否可以在任何位置找到该文件(一个简单的find.-name“libjvm.so”
就足够了)。之后,一旦你知道它们在哪里,你就可以找到你应该设置的其他环境变量,让安装程序也能正确地找到它们(我怀疑JCC_JDK
指向了错误的目录,但我无法证明)
python setup.py build
python setup.py install
PREFIX_PYTHON=/usr
ANT=ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc --shared
NUM_FILES=10
make
make test
sudo make install