首页 > 编程语言 >python3.12.3下使用flask-script的Command报错AttributeError: module 'inspect' has no attribute �

python3.12.3下使用flask-script的Command报错AttributeError: module 'inspect' has no attribute �

时间:2024-05-02 22:33:39浏览次数:16  
标签:python3.12 script flask inspect 报错 getargspec 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/commands.py下通过vim修改


最后运行

标签:python3.12,script,flask,inspect,报错,getargspec,getargs
From: https://www.cnblogs.com/skyvip/p/18170655

相关文章