python - 在 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 方法已经有一个文档字符串
解决方案
Twilio 开发人员布道者在这里。
看来这是numpy 的问题。有人建议将 numpy 降级到版本1.15.4
可能会有所帮助。
顺便说一句,我知道 pandas 教程通常会导入 numpy,但他们往往会在脚本的后面继续使用它。在这种情况下,您似乎没有在任何地方使用 numpy,那么您能否删除该导入并查看您的脚本是否仍然有效?
推荐阅读
- python - 使用 matplotlib 用颜色可视化一维数据
- python - 使用 Twitter API 提取和计算股票代码
- mysql - 从 MySQL 的多个模式中加载多个表到 R,并合并所有表
- docker - kubernetes.client.exceptions.ApiException: (0) 原因:握手状态 500 内部服务器错误
- ios - 在某些情况下,CLLocation 的 HorizontalAccuracy 是否具有无穷大的价值?
- python - Python 使用多个浏览器执行脚本 Selenium
- docker - 为 Konga docker 添加持久管理员
- swift - SwiftUI 和 MVVM - 将数据从子 View 的 ViewModel 传递到父 View 的 ViewModel
- api - 无效的文本表示:7 错误:bigint 类型的输入语法无效 - Laravel API
- sql - 如何使用 exists 获取产品的完整列表?