TypeError: sequence of byte string values expected, value of type str found
<p>I'm trying to run a simple "hello world" application using <code>mod_wsgi</code> for Python 3. I'm using Fedora 23. Here's my Apache virtual host configuration:</p>

<pre><code>&lt;VirtualHost *:80&gt;
    ServerName localhost
    ServerAdmin admin@localhost
    # ServerAlias foo.localhost
    WSGIScriptAlias /headers /home/httpd/localhost/python/headers/wsgi.py
    DocumentRoot /home/httpd/localhost/public_html
    ErrorLog /home/httpd/localhost/error.log
    CustomLog /home/httpd/localhost/requests.log combined
&lt;/VirtualHost&gt;
</code></pre>

<p>wsgi.py:</p>

<pre><code>def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-Type', 'text/plain'),
                        ('Content-Length', str(len(output)))]

    start_response(status, response_headers)

    return [output]
</code></pre>

<p>It works fine if I use <code>mod_wsgi</code> for Python 2 (<code>sudo dnf remove python3-mod_wsgi -y &amp;&amp; sudo dnf install mod_wsgi -y &amp;&amp; sudo apachectl restart</code>), but I get a 500 internal server error when using Python 3. Here's the error log:</p>

<pre><code>mod_wsgi (pid=899): Exception occurred processing WSGI script '/home/httpd/localhost/python/headers/wsgi.py'.
TypeError: sequence of byte string values expected, value of type str found
</code></pre>

<p><strong>Update</strong></p>

<p>Using <code>encode()</code> (or <code>encode('utf-8')</code>) on <code>str(len(output))</code> isn't working either. Now I get:</p>

<pre><code>Traceback (most recent call last):
  File "/home/httpd/localhost/python/headers/wsgi.py", line 8, in application
    start_response(status, response_headers)
TypeError: expected unicode object, value of type bytes found
</code></pre>