Setting up WingIDE to debug Flask project

159 Views Asked by At

Setting up Flask project in WingIDE:

from flask import Flask
app = Flask(__name__)

if __name__ == "__main__":
    import os
    if 'WINGDB_ACTIVE' in os.environ:
        app.debug = False
    app.run()

returns this error:

  File "g:\PyDev\quick\testes.py", line 4, in <module>
    from flask import Flask
builtins.ModuleNotFoundError: No module named 'flask'
1

There are 1 best solutions below

2
Wingware On

I think Wing is using a different Python installation by default, rather than the one that has Flask installed into it. You can point Wing to the right one from the Python Executable property in Project Properties. If you use a virtualenv, then that would be the virtualenv's python. Typically (in either case) this is the full path in sys.executable (after 'import sys') if you run that Python interactively outside of Wing.

In Wing 6.1.2+ you can also create a new virtualenv from Project > New Project, if creating your Wing project coincides with starting a new project in general. But if you already have your project, just change the Python Executable.