Ad

Thursday, August 23, 2018

ImportError: No module named flaskr - Python Flask Flaskr Tutorial Error Debug

Error Message

/flaskr/__init__.py", line 1, in <module> from .flaskr import app ImportError: No module named flaskr 

Related github issues

Issue 2058 https://github.com/pallets/flask/issues/2058
Issue 1902 https://github.com/pallets/flask/issues/1902
Issue 2437 The example flaskr can't easily be run by a beginner in Flask framework https://github.com/pallets/flask/issues/2437



Issue Summary

Ran into the above error because some files are put into the wrong directory and need to be moved.

Proposed solution

Better understanding of the tutorial folder structure. Here's a better diagram than the original.


flaskr/
├── MANIFEST.in
├── flaskr
│   ├── __init__.py
│   ├── flaskr.py
│   ├── schema.sql
│   ├── static
│   └── templates
└── setup.py


The indentation of the original tutorial is hard to read!

after a successful $flask run command
you will get this updated folder structure below:


flaskr/
├── MANIFEST.in
├── flaskr
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── flaskr.py
│   ├── flaskr.pyc
│   ├── schema.sql
│   ├── static
│   └── templates
├── flaskr.egg-info
│   ├── PKG-INFO
│   ├── SOURCES.txt
│   ├── dependency_links.txt
│   ├── requires.txt
│   └── top_level.txt
└── setup.py



happy coding.

Background:

I found the Flaskr tutorial through Nicole White's talk about Neo4j and Flaskr. Plus Flask is a popular python web framework. I have always wanted to code a helloworld. 

Additional documentation

https://media.readthedocs.org/pdf/flask/latest/flask.pdf
https://github.com/pallets/flask/tree/master/docs/tutorial
http://flask.pocoo.org/docs/0.12/tutorial/

2 comments:


  1. Hi I have read a lot from this blog thank you for sharing this information. We Provide all the essential topics in data science like,Python, Machine Learning,AI and Deep Learning, Tableau, etc.
    For more information just log in to our website :- Data Science course in Mumbai

    ReplyDelete

React UI, UI UX, Reactstrap React Bootstrap

React UI MATERIAL  Install yarn add @material-ui/icons Reactstrap FORMS. Controlled Forms. Uncontrolled Forms.  Columns, grid