Common errors in the Anvil Editor
This page explains common errors you may see when you run an app in the Anvil Editor and how to fix them.
Server callable defined in client code
The error @anvil.server.callable can only be used in server code appears when you use the @anvil.server.callable decorator in a Form or client Module.
The decorator makes a function in a Server Module available to client code. If the function should run only in client code, remove the decorator and call the function normally.
If the function needs to run on the server, move it into a Server Module:
import anvil.server
@anvil.server.callable
def get_message():
return "Hello from the server"Then call the function from your Form or client Module:
message = anvil.server.call('get_message')Read more about calling server functions from client code and the difference between client and server code.
Service not added
This error appears when your code uses an Anvil service that has not been added to your app. For example, code that calls anvil.users.get_user() needs the Users Service.
To add the service:
- Click the blue plus button
in the Sidebar Menu. - Select the service named in the error.
Anvil will add the service to the Sidebar Menu and add the necessary imports to your code.
Read more about adding services and integrations from the Sidebar Menu.
Do you still have questions?
Our Community Forum is full of helpful information and Anvil experts.