`pip install anthropic` currently fails on Python 3.13
Problem
One of the `anthropic` dependencies is not yet available for Python 3.13 - `tokenizers` needs `pyo3-ffi` and that's not on Python 3.13 yet: - https://github.com/PyO3/pyo3/issues/4554 This means nothing that runs Python 3.13 can `pip install anthropic` right now. Is the `tokenizers` dependency really necessary? I think it's only there for a VERY old count tokens feature which isn't actually that useful because it still uses the Claude 2 tokenizer: https://github.com/anthropics/anthropic-sdk-python/blob/cd80d46f7a223a5493565d155da31b898a4c6ee5/src/anthropic/_client.py#L270-L286
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Remove tokenizers Dependency from anthropic for Python 3.13 Compatibility
The `anthropic` package depends on the `tokenizers` library, which requires `pyo3-ffi`, not yet available for Python 3.13. This causes the installation to fail on Python 3.13 environments.
Awaiting Verification
Be the first to verify this fix
- 1
Fork the anthropic repository
Create a fork of the anthropic SDK repository on GitHub to allow modifications without affecting the main repository.
urlhttps://github.com/anthropics/anthropic-sdk-python/fork - 2
Modify setup.py to remove tokenizers
In your forked repository, locate the `setup.py` file and remove `tokenizers` from the dependencies list. This will allow the package to install without the problematic dependency.
pythondependencies = ['requests', 'other_dependencies'] # Remove 'tokenizers' - 3
Update the code to remove token counting feature
Search for any references to the token counting feature in the codebase and remove or comment them out to ensure that the package functions correctly without `tokenizers`.
python# Commenting out the token counting feature # token_count = tokenizers.count_tokens(text) - 4
Test the modified package
Install the modified package from your fork and run existing unit tests to ensure that the functionality remains intact without the `tokenizers` dependency.
bashpip install git+https://github.com/YOUR_USERNAME/anthropic-sdk-python.git - 5
Document the changes
Update the README or relevant documentation to inform users about the removal of the tokenizers dependency and any changes in functionality.
markdown## Changes - Removed tokenizers dependency for Python 3.13 compatibility.
Validation
Confirm that the installation of the modified package succeeds on Python 3.13 and that all existing functionalities, except for the removed token counting feature, work as expected.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep