我正在尝试在我的WSL Ubuntu 20.04干净安装上安装Pylucene。我试着在the official page but it looks outdated上学习教程。所以我想知道这里是否有人设法让它在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.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发布于 2020-11-20 20:39:45
以下是在Ubuntu 18.04上成功安装pylucene的步骤--这可能对你有用:
apt install openjdk-8-jre openjdk-8-jdk openjdk-8-doc如果不运行apt install ant,请确保安装了ant。请注意,如果您安装了不同版本的openjdk,则需要将其删除或运行update-alternatives以便使用版本1.8.0。使用java -version检查
cd /usr/lib/jvm
ln -s java-8-openjdk-amd64 java-8-oraclesudo apt install python-dev在我的示例中Python 3无法运行,因此我最终使用Python 2。但这可能不是问题的实际原因,因此欢迎您尝试Python 3。如果您使用Python 3,请在以下命令中使用python3而不是python。python setup.py build
python setup.py install您在步骤3中创建的符号链接在这里会有所帮助,因为此路径已硬编码到setup.py中-您可以查看这一点。
PREFIX_PYTHON=/usr
ANT=ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc --shared
NUM_FILES=10然后运行
make
make test
sudo make install--shared。发布于 2021-01-26 01:11:56
确认@code-your-dream发布的答案也适用于Python3 (尤其是在Ubuntu18.04.1)
对我来说,以这种方式安装jcc很重要。我试着通过conda安装,但是在pylucene的制作过程中出现了冲突。
在我的例子中,还需要将setup.py文件从jcc修改为'linux':‘-fno-严格别名’,‘-Wno-写-字符串’,改为'linux':‘-fno-严格别名’,‘-Wno-写-字符串’,'-D__STDC_FORMAT_MACROS',这在另一个线程Issue with installing PyLucene 6.5.0 on Linux中提到过
要确认哪个是所需的java版本(在我的例子中也是8,不适用于11),您可以在pylucene文件夹/jcc/setup.py中搜索块JDK = {...}。在我引用的例子中:'linux':'/usr/lib/jvm/java-8-oracle',
https://stackoverflow.com/questions/63452974
复制相似问题