Rohit Rayudu
Rohit Rayudu

Reputation: 3951

Trouble Importing Module

Website Logs (from Heroku:

File "app.py", line 8, in <module>

ImportError: No module named flask.ext.login

from flask.ext.login import LoginManager

Traceback (most recent call last):

File "/app/.heroku/venv/lib/python2.7/site-packages/flask/exthook.py", line 86, in load_module

I have installed Flask-Login and can see it in my folders. Why does it not work with Heroku?


Minor Update:

from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager

^SQLAlchemy import statement works here - but not login

Upvotes: 0

Views: 485

Answers (2)

Rohit Rayudu
Rohit Rayudu

Reputation: 3951

I found the error.

I had forgotten to add the extensions to

requirements.txt

Upvotes: 0

Marc Cohen
Marc Cohen

Reputation: 3808

Relative to the code doing the import (unless you're using PYTHONPATH to locate the module) you need to have a folder directory named flask/ext containing a module file named login.py (i.e. you should see a relative path to flask/ext/login.py), and the login.py module must contain the symbol LoginManager. Also you should verify that the directories in your path have an __init__.py file (this Q&A explains why). Finally, make sure you have proper access permissions for the directories (execute, for directory traversal) and the module file (read).

Upvotes: 1

Related Questions