在使用python進行GUI的程序編寫時,使用flask時出現錯誤:

在使用pip freeze進行查看已下載的包時顯示MarkupSafe與Jinjia2都已安裝:

在網上查閱一些資料后發現,在python的文件中的markupsafe文件夾中,並沒有_compat.py文件:

於是嘗試在該目錄下新建一個_compat.py文件,將以下內容復制到該文件中:
# -*- coding: utf-8 -*-
"""
markupsafe._compat
~~~~~~~~~~~~~~~~~~
Compatibility module for different Python versions.
:copyright: (c) 2013 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
import sys
PY2 = sys.version_info[0] == 2
if not PY2:
text_type = str
string_types = (str,)
unichr = chr
int_types = (int,)
iteritems = lambda x: iter(x.items())
else:
text_type = unicode
string_types = (str, unicode)
unichr = unichr
int_types = (int, long)
iteritems = lambda x: x.iteritems()
將該文件保存后,問題得以解決!

本文參考以下文章:http://www.cnblogs.com/cenariusxz/p/7436386.html