From 0817a10dc7db0efdbf6644dda44bf92ef5984ebf Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Tue, 24 Mar 2020 23:09:22 -0400 Subject: [PATCH] New Post --- content/blog/pyenvbuildflags.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 content/blog/pyenvbuildflags.md diff --git a/content/blog/pyenvbuildflags.md b/content/blog/pyenvbuildflags.md new file mode 100644 index 0000000..aeb59ee --- /dev/null +++ b/content/blog/pyenvbuildflags.md @@ -0,0 +1,20 @@ +--- +title: "Pyenv Build Flags" +date: 2020-03-24T16:58:42-04:00 +draft: false +tags: [] +--- + +I ran into an issue with PyMC3 where it was expecting a certain symbol that Python wasn't compiled with. + +``` +Exception: Compilation failed (return status=1): /usr/bin/ld: /home/rozek/.pyenv/versions/3.8.2/lib/libpython3.8.a(floatobject.o): relocation R_X86_64_PC32 against symbol `PyFloat_Type' 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. +``` + +Since I use [`pyenv`](https://brandonrozek.com/blog/pyenv/) for Python version management, it turned out that I only needed to modify the `CFLAGS` variable to get this working + +```bash +CFLAGS="-fPIC" pyenv install 3.8.2 +``` + +Turns out you can configure other flags during Python installation as well such as `CPPFLAGS` and `LDFLAGS`. \ No newline at end of file