最近在折腾apscheduler的SQLAlchemy然后配置好发现报错
TypeError: String.__init__() got an unexpected keyword argument '_warn_on_bytestring'
一直 没搞懂什么情况?后面反复查百度bing都没有相关的答案,后面就尝试把SQLAlchemy卸载掉,因为之前直接下的最新的版本,所以后面就换了2.0.0,一运行@!嘿跑起来了
这个是报错信息:
Traceback (most recent call last):
File "D:\桌面\liyqq\qiandao\new\cs.py", line 11, in <module>
'default': SQLAlchemyJobStore(url='sqlite:///jobs.sqlite')
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\apscheduler\jobstores\sqlalchemy.py", line 60, in __init__
Column('id', Unicode(191, _warn_on_bytestring=False), primary_key=True),
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\sql\sqltypes.py", line 325, in __init__
super().__init__(length=length, **kwargs)
TypeError: String.__init__() got an unexpected keyword argument '_warn_on_bytestring'
这是我的代码
import time
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.schedulers.background import BlockingScheduler
def my_job():
print('my_job, {}'.format(time.ctime()))
jobstores = {
'default': SQLAlchemyJobStore(url='sqlite:///jobs.sqlite')
}
executors = {
'default': ThreadPoolExecutor(20),
'processpool': ProcessPoolExecutor(5)
}
job_defaults = {
'coalesce': False,
'max_instances': 3
}
if __name__ == "__main__":
scheduler = BlockingScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults)
scheduler.add_job(func=my_job, trigger='interval', minutes=1, id='1', replace_existing=True, jobstore='default')
scheduler.start()
解决办法:pip会用吧
pip uninstall SQLAlchemy
然后再
pip install -v SQLAlchemy==2.0.0
3.7的话2.0.0,3.10的话得1.4.35