Issue while importing LoginManager from flask.ext.login
Question: I am trying get hands-on with flask-login extension. I am using virtualenv for
flask.

I could able to import LoginManager from flask.ext.login in the python
interpreter window, but not in the script. Below the import calls in the
script.

    
    
    from flask.ext.login import LoginManager
    

I am getting below trace.

    
    
    Traceback (most recent call last):
    File "practice/flask_login.py", line 1, in <module>
    from flask.ext.login import LoginManager
    File "/Users/sunil/co_operative/flask/lib/python2.7/site-packages/flask/exthook.py", line 81, in load_module
    reraise(exc_type, exc_value, tb.tb_next)  
    File "/Users/sunil/co_operative/practice/flask_login.py", line 1, in <module>    
    from flask.ext.login import LoginManager
    ImportError: cannot import name LoginManager
    


Answer: **Cause of problem :**

Your file name is causing problem.

**Explanation:**

As mentioned in official flask document:

<http://flask.pocoo.org/docs/0.10/extensiondev/>, when user try to import
flask extension using expression import **_flask.ext.something_** , flask will
look for module **_flask_something_**.

So, import flask.ext.login look for module flask_login which is conflicting by
your file name. And flask is trying to find Definition of LoginManager in your
file.

**Solution**

File rename will solve problem.

