4

I am trying to setup Django site with Apache and mod WSGI. When opening some pages on admin site I get an error

'ascii' codec can't encode characters in position 0-7: ordinal not in range(128)

Some more details from error screen:

Django Version:     1.7.1
Exception Type:     UnicodeEncodeError
Exception Value: 'ascii' codec can't encode characters in position 0-7: ordinal not in range(128)
Exception Location:     /var/www/.virtualenvs/tankienv/lib/python3.4/site-packages/django/utils/encoding.py in force_text, line 87
Python Executable:  /usr/bin/python

Seems that mod-wsgi uses python 2.7 instead of python 3. How should I solve this?

When I try to add path to correct python executable to apache2.conf

WSGIPythonHome /var/www/.virtualenvs/myprojectenv/bin

site stops responding.

2
  • it IS taking python3.4 (see exception location). the problem is with your encodings, not with python version Commented Nov 15, 2014 at 18:06
  • No, it was taking only additional libraries from there. And used Python 2.7. (Sorry, I have skipped this line from error screen) Commented Nov 15, 2014 at 18:09

1 Answer 1

5

The version of mod-wsgi for python3 should be installed.

I have run these commands to correct this in my Ubuntu 13.04

sudo apt-get remove libapache2-mod-wsgi
sudo apt-get install libapache2-mod-wsgi-py3 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.