Importing Libraries Issue

Hello! I have tried importing a few libraries for my code that asks questions, assigns them to values, and then uses them for calculations, and sends you a text message. However, I get this error message when I try to import them: * at src/lib/_sk_fail.py:5

  • called from src/lib/email/__init__.py:1

I’ve tried deleting the library to see what happens, but it just gave the error message to the next import line. I don’t know why.

Code Sample:

# this is a formatted code snippet.
# paste your code between ```
import smtplib #This is the line that is giving me the error
from email.mime.multipart import MIMEMultipart #I tried deleting the other line, but it then gave the error message to this line.
from email.mime.text import MIMEText
import time
from ._anvil_designer import Form1Template
import anvil.tables as tables
from anvil.tables import app_tables
from anvil import *
import anvil.server 

It looks like you are trying to import email related packages on the client side.

The python version running on the client is limited and doesn’t allow to pip install or import those packages. The client should make a call to the server where there is real python that can do the job for you.

I also would like to remind you that Anvil has its own email service that allows apps to both send and receive emails.

3 Likes

I am actually using this to send text messages to a phone using smtplib and MIMEMultipart. Would using the anvil email network still do this?

I have no experience with text messages.

Perhaps this will help you: Any recommend a good SMS provider? - #2 by anthonys