当前位置: 动力学知识库 > 问答 > 编程问答 >

python - 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

网友答案:

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).

网友答案:

I found the error.

I had forgotten to add the extensions to

requirements.txt

分享给朋友:
您可能感兴趣的文章:
随机阅读: