python wsgi pymorphy2 error iternal
<p>trying to return value of pymorphy2 using apache with wsgi module &amp; getting error 500
log says  TypeError: sequence of byte string values expected, value of type Parse found</p>

<p>i dont know what to do! in Python im rookie</p>

<p>my python code is</p>

<pre><code>import pymorphy2
import cgi

morph = pymorphy2.MorphAnalyzer()
morphid = morph.parse(u'ÐºÐ¾Ð½Ñ')

def app(environ, start_response):
    words = morphid

    start_response('200 OK', [('Content-Type', 'text/html')])
    return [words]
</code></pre>

<hr>

<p>but in shell it works...  :(<br>
please help i dont understand what is form or type of var words need to me.</p>

<p>or may be that is all wrong</p>

<p>in shell result is</p>

<blockquote>
  <blockquote>
    <blockquote>
      <p>morph = pymorphy2.MorphAnalyzer()</p>
      
      <p>words = morph.parse(u'ÐºÐ¾Ð½Ñ')</p>
      
      <p>print "words"</p>
    </blockquote>
  </blockquote>
</blockquote>

<pre><code>[Parse(word=u'\xf1\xf2\xe0\xeb\xe8', tag=OpencorporaTag('LATN'), normal_form=u'\xf1\xf2\xe0\xeb\xe8', score=1.0, methods_stack=((&lt;LatinAnalyzer&gt;, u'\xf1\xf2\xe0\xeb\xe8'),))]
</code></pre>

<p>Thanks to everyone!</p>

<p>As you can see, you need to return sequence of byte string but you are returning word which is of type <code>Parse</code>. if you want the response to be exactly the same as the thing you get from the console, try</p>

<pre><code>words = str(morphid[0]).encode()
</code></pre>

<p>It will return the string of the result which is <code>encoded()</code> thus can be used as a response.</p>

python wsgi