{"id":9541,"library":"b2","title":"Backblaze B2 Command Line Tool (b2)","description":"The `b2` package provides the official Command Line Tool for Backblaze B2 cloud storage. It allows users to manage files, buckets, and account settings directly from their terminal. The current version is 4.6.0, and it follows a frequent release cadence, often patching fixes and improving compatibility with newer Python versions or underlying SDK changes.","status":"active","version":"4.6.0","language":"en","source_language":"en","source_url":"https://github.com/Backblaze/B2_Command_Line_Tool","tags":["backblaze","b2","cloud storage","cli","command-line","backup"],"install":[{"cmd":"pip install b2","lang":"bash","label":"Install B2 CLI"}],"dependencies":[{"reason":"Core library for interacting with Backblaze B2 API, used internally by the CLI.","package":"b2sdk","optional":false}],"imports":[{"note":"For programmatic access to Backblaze B2 via Python, use the `b2sdk` library instead (e.g., `from b2sdk.v3 import B2Api`). The `b2` package itself is the command-line interface.","wrong":"import b2","symbol":"b2","correct":"This package is a CLI tool and not intended for direct programmatic import."}],"quickstart":{"code":"pip install b2\nb2 authorize-account $B2_ACCOUNT_ID $B2_APPLICATION_KEY\nb2 bucket list\nb2 upload-file my-bucket-name local-file.txt remote-file-name.txt","lang":"bash","description":"First, install the `b2` CLI. Then, authorize your account using your Backblaze B2 Application Key ID and Application Key (which can be obtained from your B2 console). You can pass these as environment variables or directly. After authorization, you can list your buckets and upload files. Replace `$B2_ACCOUNT_ID`, `$B2_APPLICATION_KEY`, `my-bucket-name`, `local-file.txt`, and `remote-file-name.txt` with your actual values."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. If you must use Python 3.8, pin your `b2` dependency to a version less than 4.5.0 (e.g., `pip install \"b2<4.5.0\"`).","message":"Support for Python 3.8 was officially dropped starting with `b2` version 4.5.0.","severity":"breaking","affected_versions":">=4.5.0"},{"fix":"Upgrade `b2` to version 4.5.0 or later (`pip install --upgrade b2`), which includes a fix for this issue.","message":"On Python 3.14+, users might encounter `SystemError: <built-in function _io_q_write_impl> returned a result with an error set` due to a buffer overflow in a dependency's terminal size detection.","severity":"gotcha","affected_versions":"<4.5.0, on Python 3.14+"},{"fix":"After installing or upgrading `b2`, run `b2 autocomplete install` to ensure autocompletion is properly configured for your shell. Refer to the `b2 autocomplete` documentation for specific shell instructions.","message":"Shell autocompletion features can be flaky or require re-installation after `b2` upgrades or Python version changes, especially on newer Python versions (3.12+, 3.14+).","severity":"gotcha","affected_versions":"<4.6.0, various Python versions"},{"fix":"For programmatic Python access, `pip install b2sdk` and use `from b2sdk.v3 import B2Api` for up-to-date functionality.","message":"The `b2` CLI internally migrated to `b2sdk.v3` in v4.4.0. While this primarily impacts the underlying implementation, it signifies a major internal change. Users attempting to interact with B2 programmatically via Python should directly use `b2sdk` (specifically `b2sdk.v3`), not attempt to import internal components from the `b2` CLI package.","severity":"gotcha","affected_versions":">=4.4.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"To use the Backblaze B2 API programmatically in Python, install and use the `b2sdk` library (`pip install b2sdk`). To run the CLI, execute `b2` commands directly in your terminal.","cause":"The `b2` Python package is designed as a command-line tool, not a library for direct programmatic `import` in Python scripts.","error":"ModuleNotFoundError: No module named 'b2'"},{"fix":"Upgrade your Python environment to version 3.9 or higher. Alternatively, if you cannot upgrade Python, install an older compatible version of `b2` using `pip install \"b2<4.5.0\"`.","cause":"You are attempting to run `b2` version 4.5.0 or newer on an unsupported Python version (e.g., Python 3.8).","error":"Error: This version of b2 requires Python >=3.9"},{"fix":"Upgrade your `b2` installation to version 4.5.0 or newer by running `pip install --upgrade b2`.","cause":"A buffer overflow issue occurring with `rst2ansi` dependency's terminal size detection on Python 3.14+, fixed in `b2` v4.5.0.","error":"SystemError: <built-in function _io_q_write_impl> returned a result with an error set"},{"fix":"Verify your Backblaze B2 Application Key ID and Application Key in your B2 console. Ensure they are correctly entered and possess the required permissions. Re-run `b2 authorize-account <keyId> <applicationKey>` with the correct credentials.","cause":"The `applicationKeyId` or `applicationKey` provided during `b2 authorize-account` is incorrect, or the key lacks the necessary permissions for the attempted operation.","error":"Unauthorized: Credentials not valid"}]}