from tavily import tavilyclient
Fixes the Python ImportError from `from tavily import tavilyclient`: the class is TavilyClient with capital T and C. Use when the import fails with cannot import name, or when wiring the Tavily search API into a script. Not for a missing tavily package install or direct REST calls.
TL;DR
The class name is TavilyClient with capital T and C. Write from tavily import TavilyClient and the import works.
from tavily import tavilyclientUse this when
- Python raises
ImportError: cannot import name 'tavilyclient' from 'tavily'. - You are wiring the Tavily search API into a script or agent.
- You followed an example that used the old lowercase client name.
Not for this skill when
- The error is about the
tavilypackage not being installed at all. That is a pip install problem, not an import-name problem. - You call the Tavily REST API directly with requests. No client class needed.
Steps
- Confirm the exact error: run the import in a REPL. Expected:
ImportError: cannot import name 'tavilyclient'. - Replace the import line with
from tavily import TavilyClient. Verify: the import succeeds with no error. - Instantiate the client:
client = TavilyClient(). It reads TAVILYAPIKEY from the environment automatically. Verify:type(client).__name__printsTavilyClient. - Make a test call:
client.search("test query", max_results=1). Verify: the response dict contains aresultslist.
Variant phrasings
cannot import name tavilyclient
Same fix. The name on the package is TavilyClient.
tavily python client import error
Covers the general search for this failure.
ImportError tavily
Short form of the same failure.
Compatibility: tavily-python 0.3+. Older 0.2.x versions exported a lowercase client; pin or upgrade before changing the import.
Why it happens
Early tavily-python versions exported a lowercase tavilyclient class. The package renamed it to the PEP-8 style TavilyClient in 0.3.x, and examples copied from old docs or old forum posts still use the lowercase name, which no longer exists in the package.
Edge cases / pitfalls
- A file named
tavily.pyin your working directory shadows the installed package. Rename the file. - Virtualenvs with a stale 0.2.x install keep exporting the old name. Run
pip show tavilyand upgrade. - Read the key from the environment or a secret store. Never paste it into the script or print it.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstg3Aj20z-PJlG7f5JCmA
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.