谁能解释一下在pythonanywhere中使用ntplib时的这个错误?

问题描述 投票:0回答:1

我在我的程序中使用NTPlib,它在我的机器上运行得很好,但当我从pythonanyhere调度它运行时,我得到以下错误。File "/home/somasundharam/.local/lib/python2.7/site-packages/ntplib.py", line 306, in request s.sendto(query_packet.to_data(), sockaddr) error: [Errno 1] Operation not permitted

我应该怎么做才能避免这种情况?

下面是代码。

我忽略了添加邮件部分的代码 因为它是从网上复制的 我在Python 2.7中运行这个gm,因为... ... firebase 代码中使用的库有一个术语 async 用来作为变种名,而这恰好是python 3.7中的一个关键字,在我的机器上,我把它改成了smthg else,比如 asyncx 它的工作正常,但我不知道如何改变同样的在 pythonanywhere

我安装了所有的软件包,使用 pip2.7 命令在前面提到的python 2.7上运行。

#!/usr/bin/python2.7
# coding: utf-8 
from firebase import firebase
import ntplib
from time import ctime
import pandas as pd
firebase = firebase.FirebaseApplication("https://@#$%^&.firebaseio.com/" , None)
c = ntplib.NTPClient()
response = c.request('asia.pool.ntp.org', version=3)
date_str = ctime(response.tx_time).split()
filename = date_str[0]+'_'+date_str[1]+'_'+date_str[2]+'_'+date_str[4]+".csv"
recipients = firebase.get("mailing list" , '')
mail_ids = list(recipients.values())
time_stamp = firebase.get("Time stamp" , '')
temp = firebase.get("TEMP SENSOR",'')
gas = firebase.get("GAS SENSOR", '')
humidity = firebase.get("HUMIDITY SENSOR",'')
sendata = [list(time_stamp.values()) ,list(temp.values()) , list(gas.values()) , list(humidity.values())]
sensor = pd.DataFrame(sendata)
sensor = sensor.transpose()
sensor.columns= ["Time Stamp","Temperature(deg C)" , "Gas Sensor(V)" , "Humidity(%)"]
sensor.to_csv(filename , index = False)

谢谢。

pythonanywhere
1个回答
0
投票

这是因为PythonAnywhere的免费用户被限制在HTTPHTTPS站点的白名单中。https:/www.pythonanywhere.comwhitelist

© www.soinside.com 2019 - 2024. All rights reserved.