ImportError: cannot import name 'Anthropic' from 'anthropic'
Problem
Trying to run the basic code for Anthropic and getting this error: AttributeError: module 'anthropic' has no attribute 'Anthropic' Using anthropic == 0.3.6 Code in my notebook: from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT anthropic = Anthropic( defaults to os.environ.get("ANTHROPIC_API_KEY") api_key='replaced with my actual api key', ) completion = anthropic.completions.create( model="claude-2", max_tokens_to_sample=300, prompt=f"{HUMAN_PROMPT} how does a court case get to the Supreme Court? {AI_PROMPT}", ) print(completion.completion)
Error Output
error: AttributeError: module 'anthropic' has no attribute 'Anthropic'
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: ImportError: cannot import name 'Anthropic' from 'anthropic'
It works in a python shell but not in my anaconda jupyter notebook.
Trust Score
1 verification
- 1
It works in a python shell but not in my anaconda jupyter notebook.
It works in a python shell but not in my anaconda jupyter notebook.
Validation
Resolved in anthropics/anthropic-sdk-python GitHub issue #86. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep