AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10c49a668> ignored
Question: I'm trying to implement my coursera python project in flask environment. Also
I'm using the <https://github.com/miguelgrinberg/flasky> (branch 7a) to
understand how the blueprints work. Now, I define 2 blueprints: main_blueprint
& rpsls_blueprint. And get the following error after running application:

    
    
    Traceback (most recent call last):
      File "manage.py", line 8, in <module>
        app = create_app(os.getenv('FLASK_CONFIG') or 'default')
      File "..../app/__init__.py", line 29, in create_app
        app.register_blueprint(rpsls_blueprint)
      File "/Library/Python/2.7/site-packages/flask/app.py", line 62, in wrapper_func
        return f(self, *args, **kwargs)
      File "/Library/Python/2.7/site-packages/flask/app.py", line 880, in register_blueprint
        if blueprint.name in self.blueprints:
    AttributeError: 'module' object has no attribute 'name'
    Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10c49a668> ignored
    

Does someone know where the problem is? Here is the related part of my
`app/__init__.py` file:

    
    
    def create_app(config_name):
        app = Flask(__name__)
        app.config.from_object(config[config_name])
        config[config_name].init_app(app)
    
        bootstrap.init_app(app)
        mail.init_app(app)
        moment.init_app(app)
        db.init_app(app)
    
        from .main import main as main_blueprint
        app.register_blueprint(main_blueprint)
    
        from .rpsls import rpsls as rpsls_blueprint
        app.register_blueprint(rpsls_blueprint)
    
        return app
    

Here is my app/rpsls/rpsls.py file:

    
    
    import random
    
    class RpslsGame():
        def __init__(self):
            pass
    
        def name_to_number(self, name):
            if name == "rock":
                return 0
            elif name == "Spock":
                return 1
            elif name == "paper":
                return 2
            elif name == "lizard":
                return 3
            elif name == "scissors":
                return 4
            else:
                return name + " does not match any\
                                of the five correct input strings"
    
        def number_to_name(self, number):
            if number == 0:
                return "rock"
            elif number == 1:
                return "Spock"
            elif number == 2:
                return "paper"
            elif number == 3:
                return "lizard"
            elif number == 4:
                return "scissors"
            else:
                return str(number) + \
                    "  is not in the correct range"
    
        def rpslsMethod(self, player_choice):
            result = ""
            result += "Player chooses " + str(player_choice) + "\n"
            player_number = self.name_to_number(player_choice)
            comp_number = random.randrange(0, 5)
            comp_choice = self.number_to_name(comp_number)
            result += "Computer chooses " + comp_choice + "\n"
            differene = (comp_number - player_number) % 5
            if (differene == 1 or differene == 2):
                result += "Computer wins\n"
            elif (differene == 3 or differene == 4):
                result += "Player wins\n"
            elif (differene == 0):
                result += "Try again, It's a tie\n"
    
            return result
    

My app/rpsls/**init**.py file:

    
    
    from flask import Blueprint
    rpsls = Blueprint('rpsls', __name__)
    from . import views
    


Answer: You imported the `rpls` module from the `rpls` package. That's a _module_ ,
not a blueprint object.

You cannot register a module as a blueprint; you can only register
[`flask.Blueprint()`
instances](https://flask.readthedocs.org/en/latest/api/#flask.Blueprint). You
may want to read up on how [Flask Blueprints
work](https://flask.readthedocs.org/en/latest/blueprints/).

You have both a `rpls` object in the `rpls` package, _and_ a submodule. When
the `app.rpls.rpls` module is imported, it **replaced** the `rpls` `Blueprint`
instance in your `__init__.py` file; the namespaces are not separate.

Rename one or the other; the module or the `Blueprint` object.

