Home > Enterprise >  why is my flask API project can't run, am trying to run it through my window command line but a
why is my flask API project can't run, am trying to run it through my window command line but a

Time:01-29

Usage: python -m flask run [OPTIONS] Try 'python -m flask run --help' for help.

Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last): File "C:\Users\Dreams Reality\AppData\Roaming\Python\Python38\site-packages\flask\cli.py", line 218, in locate_app import(module_name) File "C:\Users\Dreams Reality\Desktop\api\app.py", line 2, in from flask_restplus import Api, Resource, fields File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus_init_.py", line 4, in from . import fields, reqparse, apidoc, inputs, cors File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus\fields.py", line 17, in from werkzeug import cached_property ImportError: cannot import name 'cached_property' from 'werkzeug' (C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\werkzeug_init_.py)

I tried running my flask project using 'python -m flask run' I expected to take a good look at my project on localhost, And am getting this:

Try 'python -m flask run --help' for help.

Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last): File "C:\Users\Dreams Reality\AppData\Roaming\Python\Python38\site-packages\flask\cli.py", line 218, in locate_app import(module_name) File "C:\Users\Dreams Reality\Desktop\api\app.py", line 2, in from flask_restplus import Api, Resource, fields File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus_init_.py", line 4, in from . import fields, reqparse, apidoc, inputs, cors File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus\fields.py", line 17, in from werkzeug import cached_property ImportError: cannot import name 'cached_property' from 'werkzeug' (C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\werkzeug_init_.py)

CodePudding user response:

flask-restplus does not appear to have been updated for several years[1]. Since then, Werkzeug moved cached_property[2].

In your position, I'd drop flask-restplus and either choose an actively maintained rest package for flask, or roll your own.

[1] https://github.com/noirbizarre/flask-restplus [2] https://werkzeug.palletsprojects.com/en/1.0.x/changes/

CodePudding user response:

it seems like some of your packages aren't compatible with each other. try checking your dependencies

  • Related