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/

1 comment:

Getting Started Coding Amazon Alexa Skills for Developers

Getting Started First read our blog post on how to get started with Alexa Skill building or watch our youtube video on the topic Blog...