{"record":{"id":"947dca6bf3be9a49","repo":"oobabooga/textgen","slug":"flask-cloudflared-not-installed-make-sure-you-ins","errorCode":null,"errorMessage":"flask_cloudflared not installed. Make sure you installed the requirements.txt for this extension.","messagePattern":"flask_cloudflared not installed\\. Make sure you installed the requirements\\.txt for this extension\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"modules/api/utils.py","lineNumber":35,"sourceCode":"    # Encode bytes into base64\n    encoded_bytes = base64.b64encode(bytes_array)\n\n    # Turn raw base64 encoded bytes into ASCII\n    ascii_string = encoded_bytes.decode('ascii')\n    return ascii_string\n\n\ndef debug_msg(*args, **kwargs):\n    if int(os.environ.get(\"OPENEDAI_DEBUG\", 0)):\n        print(*args, **kwargs)\n\n\ndef _start_cloudflared(port: int, tunnel_id: str, max_attempts: int = 3, on_start: Optional[Callable[[str], None]] = None):\n    try:\n        from flask_cloudflared import _run_cloudflared\n    except ImportError:\n        print('You should install flask_cloudflared manually')\n        raise Exception(\n            'flask_cloudflared not installed. Make sure you installed the requirements.txt for this extension.')\n\n    for _ in range(max_attempts):\n        try:\n            if tunnel_id is not None:\n                public_url = _run_cloudflared(port, port + 1, tunnel_id=tunnel_id)\n            else:\n                public_url = _run_cloudflared(port, port + 1)\n\n            if on_start:\n                on_start(public_url)\n\n            return\n        except Exception:\n            traceback.print_exc()\n            time.sleep(3)\n\n    raise Exception('Could not start cloudflared.')","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/oobabooga/textgen/blob/ed888c71f221df552750e1834b3654abab8ae345/modules/api/utils.py#L17-L53","documentation":"Raised by _start_cloudflared (modules/api/utils.py:35) when starting with --public-api but the flask_cloudflared package is not importable. The tunnel cannot be created, so the exception aborts API startup for the public URL path.","triggerScenarios":"Launching with --api --public-api in an environment where 'from flask_cloudflared import _run_cloudflared' raises ImportError (package absent, or present but broken/incompatible Python).","commonSituations":"Installed only requirements.txt for the main app but not the extension/API extras; using a manually built venv that skipped optional deps; renamed/removed package in newer requirement sets; wrong venv activated.","solutions":["pip install flask-cloudflared (project name uses a hyphen) into the same environment running server.py.","If it still fails, verify with: python -c 'from flask_cloudflared import _run_cloudflared'.","Long term, drop --public-api and expose the API over LAN (--listen) behind your own reverse proxy/tunnel."],"exampleFix":"# before\npython server.py --api --public-api\n# Exception: flask_cloudflared not installed...\n\n# after\npip install flask-cloudflared\npython server.py --api --public-api\n","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec('flask_cloudflared') is None and USE_PUBLIC_API:\n    raise SystemExit('pip install flask-cloudflared before using --public-api')\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add flask-cloudflared to your deployment requirements whenever --public-api is in the start script.","Run a dependency preflight check before server launch in container images.","Pin the package version so upstream renames can't silently break imports."],"tags":["public-api","cloudflared","dependencies","startup"],"backgroundTag":null,"analyzedSha":"ed888c71f221df552750e1834b3654abab8ae345","analyzedAt":"2026-08-15T05:24:21.000Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}