Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade to Python 2.7.10: Target WSGI script cannot be loaded as Python module

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?

like image 896
xnx Avatar asked Nov 01 '22 02:11

xnx


1 Answers

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.

like image 117
kenorb Avatar answered Jan 04 '23 15:01

kenorb