ModuleNotFoundError: No module named 'flask._compat'


Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/", line 256, in locate_app
  File "/test_archived/", line 6, in <module>
    from flask_api import FlaskAPI
  File "/usr/local/lib/python3.7/site-packages/flask_api/", line 1, in <module>
    from import FlaskAPI
  File "/usr/local/lib/python3.7/site-packages/flask_api/", line 4, in <module>
    from flask._compat import reraise, string_types, text_type
ModuleNotFoundError: No module named 'flask._compat'

I tried with python version 3.6 & 3.7. Also tried flask 1.1.1, 1.1.4 & 2.0.0. But Error isn’t fixing.

import os
import logging

from argparse import ArgumentParser
from flask import request
from flask_api import FlaskAPI

Error throwing FlaskAPI import
How I fixed this error?


I had the same issue, and, finally, I defined in the requirements.txt the versions for both flask and werkzeug:


Answered By – Moi Syme

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published