jep icon indicating copy to clipboard operation
jep copied to clipboard

pip install . fails

Open patenaud opened this issue 1 year ago • 7 comments

I get this error when trying to install via pip (pip install jep) or local source install (pip install .). Java and numpy requirements are installed. Runnin a python 3.11 virtual env.

/usr/bin/ld: /usr/local/lib/libpython3.11.a(ast_opt.o): warning: relocation against PyExc_RecursionError' in read-only section .text.unlikely' /usr/bin/ld: /usr/local/lib/libpython3.11.a(abstract.o): relocation R_X86_64_PC32 against symbol `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status error: command '/usr/bin/gcc' failed with exit code 1

java --version openjdk 17.0.6 2023-01-17 LTS OpenJDK Runtime Environment Corretto-17.0.6.10.1 (build 17.0.6+10-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.6.10.1 (build 17.0.6+10-LTS, mixed mode, sharing)

numpy==1.24.2

$PATH /home/devop/py311_venv/bin:/usr/lib/jvm/java-17-amazon-corretto/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/opt/gradle/gradle-8.0.2/bin

patenaud avatar Apr 04 '23 14:04 patenaud

We do not support building with a python installation with a statically linked libpython(libpython3.11.a). I recommend installing a version of python that provides a dynamically linked libpython(libpython3.11.so).

bsteffensmeier avatar Apr 04 '23 15:04 bsteffensmeier

Thank you. I was able to install jep outside of my 3.11.2 python virtual env. I'm not sure why. I've got "googling" to do to better understand virtual environments.

patenaud avatar Apr 04 '23 17:04 patenaud

Hi Nate and Ben,

I experienced this problem when trying to pip install jep in a venv. It turns out the linker looks in ~/.local/lib for the libpython3XX.so library, but it is not there, it is in the site installation area, in /usr/lib/x86_64-linux-gnu (for Mint/Ubuntu). There is a static library in the local lib dir, which causes the error. I carefully searched through the wiki and tried setting LD_LIBRARY_PATH, LD_PRELOAD, LIBDIR and LDLIBRARY, but nothing worked. I finally got it to work by putting a link in ~/.local/lib to the site installation library:

libpython3.10.so -> /usr/lib/x86_64-linux-gnu/libpython3.10.so

Is there a better way to do this when working with a venv?

Thanks! Erik

svensk-pojke avatar May 11 '23 16:05 svensk-pojke

I don't know much about venv but I do have a variety of Dockerfiles that I use to test jep in various environments. Here is a Dockerfile that I use to test venv and it works without any extra linking. I recommend you compare that env to what you are using.

FROM python:3.10
RUN apt-get update && apt-get install --no-install-recommends -y openjdk-17-jdk-headless && apt-get clean
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
WORKDIR /jep
RUN python3.10 -m venv venv-dir
RUN . venv-dir/bin/activate && pip install numpy
RUN . venv-dir/bin/activate && pip install jep

CMD /jep/venv-dir/bin/jep

bsteffensmeier avatar May 12 '23 19:05 bsteffensmeier

Thanks for the response, Ben. I think this must be some kind of configuration issue on my end. I just tried pip installing jep on a laptop running Mint 21.1 (Ubuntu 22.04) and everything works fine. It still fails on my other machine, which is Mint 20.3 (Ubuntu 20.04). I used essentially the same steps that you outline above. I plan to upgrade my other machine anyway, so this is not an issue. Thanks again for the response.

svensk-pojke avatar May 13 '23 16:05 svensk-pojke

I having exactly the same issue! I just tried to run the same commands you have in dockerfile.. no way, I got the following error:

      /usr/bin/ld: /usr/local/lib/libpython3.10.a(myreadline.o): relocation R_X86_64_PC32 against symbol `_PyOS_ReadlineTState' can not be used when making a shared object; recompile with -fPIC
      /usr/bin/ld: /usr/local/lib/libpython3.10.a(mystrtoul.o): relocation R_X86_64_PC32 against symbol `_Py_ctype_table' can not be used when making a shared object; recompile with -fPIC
      /usr/bin/ld: final link failed: nonrepresentable section on output
      collect2: error: ld returned 1 exit status

Do you have any other tips?

enricostara avatar Apr 22 '24 10:04 enricostara

If you compiled your own python, you need to recompile it with the --enable-shared flag passed to configure.

ndjensen avatar Apr 22 '24 19:04 ndjensen