vicious-gold
vicious-gold6mo ago

Python SDK error

Hi guys. I used vapi_python library as it in the github and it says cannot import name 'Vapi' from 'vapi_python'. I'll attach the code
from vapi_python import Vapi

def run_with_existing_assistant():
vapi = Vapi(api_key='xxx')

try:
print("Starting call with existing assistant...")
vapi.start(
assistant_id='xxx',
assistant_overrides={
'variableValues': {
'name': 'John'
}
}
)

input("Press Enter to end the call...")

finally:
vapi.stop()
print("Call ended.")

if __name__ == "__main__":
run_with_existing_assistant()
from vapi_python import Vapi

def run_with_existing_assistant():
vapi = Vapi(api_key='xxx')

try:
print("Starting call with existing assistant...")
vapi.start(
assistant_id='xxx',
assistant_overrides={
'variableValues': {
'name': 'John'
}
}
)

input("Press Enter to end the call...")

finally:
vapi.stop()
print("Call ended.")

if __name__ == "__main__":
run_with_existing_assistant()
5 Replies
Vapi Support Bot
Try reinstalling the package to ensure you have the latest version and that Vapi is exposed at the top level.
Run:
pip install --upgrade --force-reinstall vapi_python
pip install --upgrade --force-reinstall vapi_python
Then, try your import again. If the error persists, check that there is no local file named vapi_python.py in your project directory, as this can shadow the installed package. Source: - Vapi Python SDK GitHub
⤵️ Mention @Vapi Support Bot for follow-ups 🐥
grumpy-cyan
grumpy-cyan6mo ago
Try upgrading the package and importing with from vapi import Vapi, or use direct API calls with requests if the SDK still doesn’t work..
Vapi Support Bot
It looks like you've already tried some common troubleshooting steps for this import error, such as reinstalling the package and checking for any local files that might shadow the installed package. Another approach you could try is importing with from vapi import Vapi instead of from vapi_python import Vapi, as sometimes the import path can change between versions. If the issue persists, using direct API calls with the requests library is also an option. Let me know if any of these steps help!
vicious-gold
vicious-goldOP6mo ago
I tried vapi import Vapi. It said it doen't have methods of start and end.
Vapi Support Bot
Please ensure you are using the official import path as shown below, and that there is no file named vapi_python.py in your project directory:
from vapi_python import Vapi
from vapi_python import Vapi
If you still get the import error, try running:
pip install --upgrade --force-reinstall vapi_python
pip install --upgrade --force-reinstall vapi_python
and restart your Python environment. This should expose the Vapi class with the correct methods (Vapi Python SDK GitHub). Source: - Vapi Python SDK GitHub

Did you find this page helpful?