我有一组用 python 编写的爬虫,我试图在 Heroku 上托管。我已将 repo 推送到 heroku,它将开始运行,但退出时出现我在本地环境中从未遇到过的错误。
当我打电话给p = Legislator(name=name, district=district)
名字和地区都是字符串的地方时,我得到了TypeError: __init__() takes at least 3 arguments (2 given)
Legislator 和 Person 都包含在我的脚本所依赖的包中,这两者都在requirements.txt
这是否与 virtualenv 有关系?
这是立法者的构造函数:
def __init__(self, name, post_id, party=None, chamber=None, **kwargs):
super(Legislator, self).__init__(name, **kwargs)
self.post_id = post_id
self.party = party
self.chamber = chamber
self._contact_details = []
和 Person 的构造函数
def __init__(self, name, **kwargs):
super(Person, self).__init__()
self.name = name
self.biography = None
self.summary = None
self.birth_date = None
self.death_date = None
self.image = None
self.gender = None
self.links = []
self.other_names = []
self.extras = {}
self._related = []
self.contact_details = []
for k, v in kwargs.items():
setattr(self, k, v)