首页 > 解决方案 > 在 Pythonanywhere 文件中导入多个模块时遇到问题

问题描述

尝试在 pythonanywhere 上运行此代码,以便在早上向即将接受采访的人发送自动提醒。它在我第一次运行 pythonanywhere.py 文件时工作,但随后每次都会中断。.ipynb 文件不会发生此错误。

#Import pandas for dataframes
#Import datetime to check day 
import numpy as np
import pandas as pd 
import datetime
import requests 
from twilio.rest import Client

#datetime_object = datetime.datetime.now() #Get current time
today = datetime.date.today() #Get current day 
today = pd.Timestamp(today) #Convert current day into usable formate
interviewees = pd.ExcelFile('/home/drblessing/InterviewCandidates.xlsx') #Load in list of interview candidates
interviews_df = interviewees.parse() #Parse interview candidates into dataframe
Reminders = (interviews_df['Date'] - datetime.timedelta(days=1)) #Take their interview day and subtract one to send out reminder
Reminders_df = interviews_df[Reminders == today] #Checking which candidates have reminders today 
Reminder_phones = pd.Series.tolist(Reminders_df['Phone'])
Reminder_emails = pd.Series.tolist(Reminders_df['Email'])
account_sid = '****************************'
auth_token = '5**************************'
client = Client(account_sid, auth_token)

for i in Reminder_phones:
    message = client.messages.create(
                              body='Hi there! This is an automated message to remind you about your interview on 2/20 at 1:00 pm. ',
                              from_='**********',
                              to=['******************']
                          )
    print(message.sid)

def send_simple_message():
    return requests.post(
        "https://api.mailgun.net/v3/dbless.net/messages",
        auth=("api", "*********************************"),
        data={"from": "urmom <mailgun@dbless.net>",
            "to": Reminder_emails,
            "subject": "Test",
            "text": "I had to show python who's BOSS "})

send_simple_message()

但是,在第一次运行后,我收到此错误:

RuntimeError:implement_array_function 方法已经有一个文档字符串

标签: pythonnumpypythonanywhere

解决方案


Twilio 开发人员布道者在这里。

看来这是numpy 的问题。有人建议将 numpy 降级到版本1.15.4可能会有所帮助。

顺便说一句,我知道 pandas 教程通常会导入 numpy,但他们往往会在脚本的后面继续使用它。在这种情况下,您似乎没有在任何地方使用 numpy,那么您能否删除该导入并查看您的脚本是否仍然有效?


推荐阅读