5

When I upgrade Python from 2.7.9 to 2.7.10 with anaconda, I get the following error in my apache2 log and my websites don't work any more.

mod_wsgi (pid=608): Target WSGI script '/www/wsgi_scripts/django_myproject.wsgi' cannot be loaded as Python module.
 Exception occurred processing WSGI script '/www/wsgi_scripts/django_myproject.wsgi'.
Traceback (most recent call last):
  File "/www/wsgi_scripts/django_myproject.wsgi", line 8, in <module>
    import django.core.handlers.wsgi
  File "/Users/xnx/anaconda/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 6, in <module>
    from io import BytesIO
  File "/Users/xnx/anaconda/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/Users/xnx/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
  Referenced from: /Users/xnx/anaconda/lib/python2.7/lib-dynload/_io.so
  Expected in: dynamic lookup

I expect this is some kind of mismatch in package library versions, but does anyone know which one?

xnx
  • 24,509
  • 11
  • 70
  • 109
  • Did you try rebuilding/reinstalling mod_wsgi? If using a Python virtual environment, did you recreate the Python virtual environment after the Python upgrade? Upgrading Python can often cause existing Python virtual environments to stop working. – Graham Dumpleton Jun 05 '15 at 21:11
  • Thanks for your response, Graham. I did reinstall mod_wsgi using pip, but I get the same error unless I downgrade Python. – xnx Jun 06 '15 at 01:30
  • Are you saying you are running ``mod_wsgi-express`` or are you using system wide Apache? If system wide, how has system Apache setup to know where to pick up mod_wsgi.so from? Doing a ``pip install mod_wsgi`` doesn't install the mod_wsgi '.so' file into system Apache modules directory and that would have to be done as a separate step if system Apache had been set up to pull it from system Apache modules directory. – Graham Dumpleton Jun 06 '15 at 03:51

2 Answers2

1

My suspicion is that this is a problem with Anaconda as I've just hit the same problem. I've reported an issue here: https://github.com/conda/conda/issues/1367

update:

The conda guys have now released a fixed virtualenv package that no longer has this problem.

Chris Withers
  • 10,837
  • 4
  • 33
  • 51
  • 1
    Thanks - despite my earlier comment (now deleted) I haven't been able to resolve this by recompiling and reinstalling mod_wsgi, so I think you're right: a problem with Anaconda. – xnx Jun 09 '15 at 12:56
1

Double check your PYTHONPATH if it's correct (you don't override it anywhere in your startup files).

Otherwise you may consider downgrading your Python from 2.7.10 to 2.7.9.

For example (as suggested in here):

conda install python=2.7.9

or when using Homebrew try:

brew switch python 2.7.9

as it could be some particular problem with 2.7.10.

Alternatively use Python 3.x instead.

Community
  • 1
  • 1
kenorb
  • 155,785
  • 88
  • 678
  • 743
  • 1
    Yup, that's what I had to do. I can't migrate everything to Python 3, though. – xnx Aug 08 '15 at 11:50