6

i'm having this problem:

i'm runing pythonbrew to get python2.7, and so i re-compiled mod_wsgi to use the 2.7 python.

to that end, i followed this tutorial:

code.google.com/p/modwsgi/wiki/QuickInstallationGuide

which involved downloading the file - there is a tar.gz file i get - and then "configuring it" with ./configure --with-python=/home/bharal/.pythonbrew/pythons/Python-2.7.2/bin/python --enable-shared

now i'm assuming this is the right place to attach for my python - the value for with-python above is just the response i get to a which python

OK! So, now the problem. After i run the configure above, i run make and i get:

/usr/include/features.h:160:1: warning: this is the location of the previous definition
/usr/share/apr-1.0/build/libtool --silent --mode=link --tag=disable-static x86_64-linux-gnu-gcc -o mod_wsgi.la  -rpath /usr/lib/apache2/modules -module -avoid-version    mod_wsgi.lo -L/home/aiyer    /.pythonbrew/pythons/Python-2.7.2/lib -L/home/aiyer/.pythonbrew/pythons/Python-2.7.2/lib  /python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm
/usr/bin/ld: /home/bharal/.pythonbrew/pythons/Python-2.7.2/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/home/aiyer/.pythonbrew/pythons/Python-2.7.2/lib/libpython2.7.a: could not read symbols: Bad  value
collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536

And i have no idea what to do. I came across this answer is SO:

https://stackoverflow.com/a/6118155/1061426

but this doesn't help me any much - it isn't as far as i can tell a series of steps, but more an interesting tidbit to think about.

I ran this command to check if i have python 64 bit:

import sys
print maxint

if 64 bit ==> 9223372036854775807 if 32 bit ==> 2147483647

ok, so i'm totes running 64bit because i get the bigger number. So i read this doco here:

http://code.google.com/p/modwsgi/wiki/InstallationIssues#Mixing_32_Bit_And_64_Bit_Packages

because i'm running the 64 bit python, does that mean that my problem isn't this:

This error is believed to be result of the version of Python being used having been originally compiled for the generic X86 32 bit architecture whereas mod_wsgi is being compiled for X86 64 bit architecture. The actual error arises in this case because 'libtool' would appear to be unable to generate a dynamically loadable module for the X86 64 bit architecture from a X86 32 bit static library.

but rather this?

Alternatively, the problem is due to 'libtool' on this platform not being able to create a loadable module from a X86 64 bit static library in all cases.

(the above quotes from the above link)

and if that is the case, what the heck do i do? I haven't the foggiest notion what to do in either scenario - and yes, i read the rest of that page, but it might as well have been written in greek ( i don't speak greek ).

any suggestions?

UPDATE: i never fixed this and ended up using the python my ubuntu came with - no difference from the running of my code's point of view.

Community
  • 1
  • 1
bharal
  • 15,461
  • 36
  • 117
  • 195

3 Answers3

7

The documentation says:

If the first issue, the only solution to this problem is to recompile Python for the X86 64 bit architecture. When doing this, it is preferable, and may actually be necessary, to ensure that the '--enable-shared' option is provided to the 'configure' script for Python when it is being compiled and installed.

So, you need to reinstall Python from source code, ensuring the '--enable-shared' option is supplied to the 'configure' command for Python prior to running 'make'.

If 'pythonbrew' doesn't allow you to do that, then tell the pythonbrew people that the way they are building their Python version with shared library support is arguably broken and will prevent many embedded systems from failing to run.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • ? but why are we assuming that the first solution is the problem? The python i have *is* 64 bits, isn't that what it means? I mean, it can handle 64 bit integers - hence the test i showed. Admittedly i'm well out of my depth here, but i was thinking it was the second (equally insolvable) prolbme? – bharal Jul 05 '12 at 00:11
  • Being compiled as 64 bits is not the issue. It is because the Python installation does not install a shared library for Python and only installs a static library. Do you have a libpython2.7.so or only a libpython2.7.a? – Graham Dumpleton Jul 05 '12 at 03:58
  • oh well, i never fixed this and ended up using the python my ubuntu came with - no difference from the running of my code's point of view. I +1'd you, and will leave open in case someone has steps or something to do what you suggest! – bharal Jul 05 '12 at 18:18
  • should be --enable-shared not --enabled-shared – igniteflow Jul 18 '13 at 15:06
0

Having come across this problem myself with Fedora 19 64bit, I found that the mod_wsgi would compile and install from source if I installed both the Python-devel and httpd-devel packages.

I am not using pythonbrew however.

nerak99
  • 640
  • 8
  • 26
0

My Dear Python developers, I was also getting the same error, and here is how I got it fixed. The very first step is that you'll have install python with --enable-shared option. Next thing, Make sure you have dev dependencies installed for both Apache and Python. sudo apt-get install apache2-dev and sudo apt-get install python3.8-dev. I was using Python 3.8 so i install python3.8-dev. You need to install the one matching with your python version.

In addition to this, read this aricle and follow the instruction closely, given here https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html#apache-requirements

I just followed it and was able to make it work properly.

Rajan Rawal
  • 6,171
  • 6
  • 40
  • 62