{"id":930,"hash":"927467e7e318a2973baaa86ec165740264be62d5390c68ef7ce3d334015e1cce","pattern":"AttributeError: &#39;Flask&#39; object has no attribute &#39;user_options&#39;","full_message":"I am trying to setup this basic example from the following doc:\n\n  http://flask.pocoo.org/docs/patterns/celery/\n\nBut so far I keep getting the below error:\n\n  AttributeError: 'Flask' object has no attribute 'user_options'\n\nI am using celery 3.1.15.\n\nfrom celery import Celery\n\ndef make_celery(app):\n    celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])\n    celery.conf.update(app.config)\n    TaskBase = celery.Task\n    class ContextTask(TaskBase):\n        abstract = True\n        def __call__(self, *args, **kwargs):\n            with app.app_context():\n                return TaskBase.__call__(self, *args, **kwargs)\n    celery.Task = ContextTask\n    return celery\n\nExample:\n\nfrom flask import Flask\n\napp = Flask(__name__)\napp.config.update(\n    CELERY_BROKER_URL='redis://localhost:6379',\n    CELERY_RESULT_BACKEND='redis://localhost:6379'\n)\ncelery = make_celery(app)\n\n@celery.task()\ndef add_together(a, b):\n    return a + b\n\nTraceback error:\n\nTraceback (most recent call last):\n  File \"/usr/local/bin/celery\", line 11, in <module>\n    sys.exit(main())\n  File \"/usr/local/lib/python2.7/dist-packages/celery/__main__.py\", line 30, in main\n    main()\n  File \"/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py\", line 81, in main\n    cmd.execute_from_commandline(argv)\n  File \"/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py\", line 769, in execute_from_commandline\n    super(CeleryCommand, self).execute_from_commandline(argv)))\n  File \"/usr/local/lib/python2.7/dist-packages/celery/bin/base.py\", line 305, in execute_from_commandline\n    argv = self.setup_app_from_commandline(argv)\n  File \"/usr/local/lib/python2.7/dist-packages/celery/bin/base.py\", line 473, in setup_app_from_commandline\n    user_preload = tuple(self.app.user_options['preload'] or ())\nAttributeError: 'Flask' object has no attribute 'user_options'","ecosystem":"pypi","package_name":"flask","package_version":null,"solution":"The Flask Celery Based Background Tasks page (http://flask.pocoo.org/docs/patterns/celery/) suggests this to start celery:\n\ncelery -A your_application worker\n\n  The your_application string has to point to your application’s package or module that creates the celery object.\n\nAssuming the code resides in application.py, explicitly pointing to the celery object (not just the module name) avoided the error:\n\ncelery -A application.celery worker","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/25884951/attributeerror-flask-object-has-no-attribute-user-options","votes":59,"created_at":"2026-04-19T04:52:02.700011+00:00","updated_at":"2026-04-19T04:52:02.700011+00:00"}