1

i need to install mod_wsgi for Django, but when i do pip install mod_wsgi i have an error:

    /usr/local/lib/libpython2.7.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-LHF3wD/mod-wsgi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lWmQhZ-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-LHF3wD/mod-wsgi/

So i found information about this problem and i tried to reconfigure python like this:

make clean
./configure --enable-shared
make

But now i have the same error after make command:

/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

OS: CentOS 6, python version: 2.7

Also i already have mod_wsgi for Python6.6 (by default. I installed "web server" version of centos)

What is wrong? Thanks.

worm2d
  • 159
  • 1
  • 2
  • 14
  • Have you tried with `sudo`? Maybe you don't have permissions – Mr. E Apr 07 '16 at 13:08
  • @Mr.E yes, i tried – worm2d Apr 07 '16 at 13:10
  • but your error `'gcc' failed with exit status 1`. is gcc intalled? – Javier Clavero Apr 07 '16 at 13:18
  • @JavierClavero yes, gcc is installed, Python installation works fine without `--enable-shared`, but with this parameter i have the error... – worm2d Apr 07 '16 at 13:20
  • you've tried `make distclean`? and then `configure --enable-shared` – Javier Clavero Apr 07 '16 at 13:29
  • @JavierClavero yes, i tried it just now, unfortunately have the same error – worm2d Apr 07 '16 at 13:30
  • What does `echo $CFLAGS` says? – Alexey Smirnov Apr 07 '16 at 13:40
  • @AlexeySmirnov it's -fPIC – worm2d Apr 07 '16 at 13:41
  • you've tried with argument `--prefix=/usr/local`? (or path to installation python) – Javier Clavero Apr 07 '16 at 14:29
  • can you run python in cmd? Your path to python could be misconfigured – Georgina S Apr 07 '16 at 19:08
  • @GeorginaS yes, i can run python 2.7, it is installed now, but i need --enable-shared, but if i configure with it parameter it doesnt work, it shows me errors like this - `can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpython2.7.a: could not read symbols: Bad value`. @JavierClavero i tried it now with `--prefix=/usr/local` but it still doesnt work – worm2d Apr 08 '16 at 07:00
  • try running the command: ldconfig – Georgina S Apr 08 '16 at 08:10
  • @GeorginaS i run it, what should i do with it? – worm2d Apr 08 '16 at 08:12
  • try install mod_wsgi again – Georgina S Apr 08 '16 at 08:14
  • @GeorginaS the same `/usr/bin/ld: /usr/local/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 /usr/local/lib/libpython2.7.a: could not read symbols: Bad value` – worm2d Apr 08 '16 at 08:38
  • In this case it could be easier to not use pip and make mod_wsgi yourself. https://code.google.com/archive/p/modwsgi/wikis/QuickInstallationGuide.wiki should give you pretty much everything you need, just ensure you point to the correct version of python when compiling. I ran into nearly the exact same problem, but I was using python3.5 and pip3 instead. – Georgina S Apr 08 '16 at 08:47
  • mixing packages 32 and 64 bits. Try this, backup the file `mv /usr/lib64/httpd/modules/mod_wsgi.so /usr/lib64/httpd/modules/mod_wsgi.so.backup` and then create symbolic link `ln -s /usr/local/lib/python2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so /usr/lib64/httpd/modules/mod_wsgi.so` – Javier Clavero Apr 08 '16 at 08:48
  • @GeorginaS this arcticle says "Python should preferably be available as a shared library." But the same error `can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpython2.7.a: could not read symbols: Bad value` i have when install python with --enable-shared... So it make me insane :/ – worm2d Apr 08 '16 at 09:34
  • Yeah these errors are a real pain. Try running python from shell. import sysconfig, then run sysconfig.get_config_var('CCSHARED') does -fPIC come up? – Georgina S Apr 08 '16 at 09:55
  • I believe this is what you're looking for. https://stackoverflow.com/questions/16986952/how-to-ignore-local-python-when-building-python-from-source – Jobu Feb 15 '18 at 19:23

0 Answers0