Python – Error when trying install mod_wsgi using pip

mod-wsgipython

When trying to install mod_wsgi using pip as follows:

pip install mod_wsgi

I get the following error:

4m.so -L/usr/local/lib -L/usr/local/lib/python3.4/config-3.4m
-lpython3.4m
/bin/ld: /usr/local/lib/libpython3.4m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when
making a shared object; recompile with -fPIC
/usr/local/lib/libpython3.4m.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

Command "/usr/local/virtualenvironment/bin/python3 -u -c "import
setuptools,
tokenize;file='/tmp/pip-install-dgfnrl36/mod-wsgi/setup.py';f=getattr(tokenize,
'open', open)(file);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, file, 'exec'))" install
–record /tmp/pip-record-m7uwmjt6/install-record.txt –single-version-externally-managed –compile –install-headers /usr/local/virtualenvironment/include/site/python3.4/mod-wsgi" failed
with error code 1 in /tmp/pip-install-dgfnrl36/mod-wsgi/

I am using Python 3.4.3. I even tried to build mod_wsgi from source and pretty much get the same error.

From seeing this in the following in the stack trace perhaps its looking for python source or other source? I'm still fiddling around trying to figure out what it wants but any help will be appreciated.

Best Answer

The solution that worked for me was to build mod_wsgi from source after installing the python dev libraries.

So

yum install python3-devel
  1. Download desired mod_wsgi version from http://modwsgi.readthedocs.io/en/develop/
  2. Unzip the source and cd into the unzipped source folder
  3. execute the following ./configure --with-python=/path/to/python/executable
  4. make
  5. make install