PythonAnywhere Forums

import error from python 2.7.6


I'm trying to import Flask (which is one of the batteries included) after starting up python 2.7.6 but I'm getting an error ImportError: No module named Utils. This is after starting python from the bash console (Bash console 6134952)

My commands and the full error message are below:

00:37 ~ $ uname -a
Linux harry-liveconsole4 4.4.0-83-generic #106-Ubuntu SMP Mon Jun 26 17:54:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

00:37 ~ $ python

Python 2.7.6 (default, Oct 26 2016, 20:30:19)

[GCC 4.8.4] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> from flask import Flask

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/flask/", line 17, in <module>
    from werkzeug.exceptions import abort
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/", line 152, in <module>
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/", line 71, in <module>
    from werkzeug.wrappers import Response
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/", line 26, in <module>
    from werkzeug.http import HTTP_STATUS_CODES, \
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/", line 24, in <module>
    from email.Utils import parsedate_tz
ImportError: No module named Utils

Thanks for your help

[edit by admin: formatting]

Do you have a file in your home directory called, or a directory there called email that contains a file called If so, that would explain the problem.

When you run a Python interpreter, it sets up a system path that has the current working directory first. So when some code -- regardless of whether it's your own code, or something deep inside Flask, tries to import email.Utils, then it will look at your own email module first, and will fail if it can't find the Utils class/module in there.

thank you very much!

You're welcome!