{"id":255,"hash":"f8fd69f12da40e65a1d4686de565e82ad7c530d505fe3657e75a0298bf93de22","pattern":"Flask ImportError: No Module Named Flask","full_message":"I'm following the Flask tutorial here: \n\nhttp://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world\n\nI get to the point where I try ./run.py and I get:\n\nTraceback (most recent call last):\n  File \"./run.py\", line 3, in <module>\n    from app import app\n  File \"/Users/benjaminclayman/Desktop/microblog/app/__init__.py\", line 1, in <module>\n    from flask import Flask\nImportError: No module named flask\n\nThis looks similar to:\n\nImportError: No module named flask\n\nBut their solutions aren't helpful.  For reference, I do have a folder named flask which one user mentioned may cause issues.","ecosystem":"pypi","package_name":"flask","package_version":null,"solution":"Try deleting the virtualenv you created.  Then create a new virtualenv with:\n\nvirtualenv flask\n\nThen:\n\ncd flask\n\nNow let's activate the virtualenv\n\nsource bin/activate\n\nNow you should see (flask) on the left of the command line.\n\nEdit: In windows there is no \"source\" that's a linux thing, instead execute the activate.bat file, here I do it using Powershell: PS C:\\DEV\\aProject> & .\\Flask\\Scripts\\activate)\n\nLet's install flask:\n\npip install flask\n\nThen create a file named hello.py (NOTE: see UPDATE Flask 1.0.2 below):\n\nfrom flask import Flask\napp = Flask(__name__)\n\n@app.route(\"/\")\ndef hello():\n    return \"Hello World!\"\n\nif __name__ == \"__main__\":\n    app.run()\n\nand run it with:\n\npython hello.py\n\nUPDATE Flask 1.0.2\n\nWith the new flask release there is no need to run the app from your script.  hello.py should look like this now:\n\nfrom flask import Flask\napp = Flask(__name__)\n\n@app.route(\"/\")\ndef hello():\n    return \"Hello World!\"\n\nand run it with:\n\nFLASK_APP=hello.py flask run\n\nMake sure to be inside the folder where hello.py is when running the latest command.\n\nAll the steps before the creation of the hello.py apply for this case as well","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/31252791/flask-importerror-no-module-named-flask","votes":187,"created_at":"2026-04-19T04:41:39.772215+00:00","updated_at":"2026-04-19T04:51:51.425760+00:00"}