Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:13:57+00:00 2026-06-03T03:13:57+00:00

In a web-application (using Flask), I get the following error: Unable to retrieve the

  • 0

In a web-application (using Flask), I get the following error:

Unable to retrieve the thumbnail for u'/var/data/uploads/2012/03/22/12 Gerd\xb4s Banjo Trio 1024.jpg'
Traceback (most recent call last):
 File "/var/www/beta/env/lib/python2.7/site-packages/dblib-1.0dev3-py2.7.egg/dblib/orm/file.py", line 169, in get_thumbnail
   if not exists(filename):
 File "/usr/lib/python2.7/genericpath.py", line 18, in exists
   os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb4' in position 52: ordinal not in range(128)

Note that I include the repr() of the file name in the logged error. This shows that the file name is passed as a Unicode instance. So much is correct…

If I run the culprit using the python interpreter, it works as expected:

>>> from os.path import exists
>>> exists(u'/var/data/uploads/2012/03/22/12 Gerd\xb4s Banjo Trio 1024.jpg')
True

So obviously, while running in the Flask environment, Python thinks it should encode the file-name using the ASCII codec instead of UTF-8. I deployed the application using mod_wsgi behind the Apache httpd.

I assume I have to tell either one of them to use UTF-8 somewhere? But where?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:13:58+00:00Added an answer on June 3, 2026 at 3:13 am

    See Django docs for same issue. When using mod_wsgi, should be same solution:

    https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/#if-you-get-a-unicodeencodeerror

    Excerpt from the above linked doc:

    […] you must ensure that the environment used to start Apache is
    configured to accept non-ASCII file names. If your environment is not
    correctly configured, you will trigger UnicodeEncodeError exceptions
    when calling functions like the ones in os.path on filenames that
    contain non-ASCII characters.

    To avoid these problems, the environment used to start Apache should
    contain settings analogous to the following:

    export LANG='en_US.UTF-8'
    export LC_ALL='en_US.UTF-8'
    

    Consult the documentation for your operating system for the
    appropriate syntax and location to put these configuration items;
    /etc/apache2/envvars is a common location on Unix platforms. Once
    you have added these statements to your environment, restart Apache.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web application using Flask. One of the views is
I am working on an web application using flask, postgresql and sqlalchemy and coding
I have a Flask web application using SQLAlchemy with MySQL, and I have set
I'm using the actionscript api for a flash application on the web. I would
I am building a Web Application using asp.net (C#). I come from windows forms
I am building a web application using ASP.NET MVC that has two very distinct
I'm writing a web application using the Catalyst framework . I'm also using a
I have this web application using Spring Web Flow framework. In my main page
I am designing a web application using the ASP.net MVC framework. I would like
I am developing an web application using php. One of the requirement is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.