python3.12.3下使用flask-script的Command报错AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?

错误如下图:

问题原因:
因为inspect.getargspec 在 3.11+ 中已弃用。
翻看源码如下图

解决方案:
解决方法是使用 inspect.fullargspec 代替,并添加 3 个虚拟变量,因为 getfullargspec 将返回 7 个项目而不是 4 个:

args, varargs, keywords, defaults, foo, foo1, foo2 = inspect.getfullargspec(func)

Window下按住Ctrl进入Command.py下修改

linux下进入报错路径/usr/local/lib/python3.12/site-packages/flask_script/下通过vim commands.py修改


最后运行

参考:
https://community.privacyidea.org/t/python-3-11-support/3115/2

posted @ 2024-05-02 22:28  Excel2016  阅读(41)  评论(0编辑  收藏  举报