ImportError: cannot import name ‘getargspec‘ from ‘inspect‘

问题:

 ImportError: cannot import name 'getargspec' from 'inspect'

 解决办法

根据错误提示点击到 expressions.py 文件然后在文件中执行以下操作即可

这个错误消息表明您试图从 inspect 模块导入 getargspec 函数,但该函数已从 Python 3.0 开始不再可用。这是因为该函数已被弃用,并且应该使用替代方法替换。

对于 Python 2.7 和更早版本,您可以使用 inspect.getargspec 函数获取函数的参数信息。对于 Python 3.x,您可以使用 inspect.signature 函数替代:

import inspect

def my_func(arg1, arg2, kwarg1=None):
    pass

# Python 2.7 and earlier
argspec = inspect.getargspec(my_func)

# Python 3.x
sig = inspect.signature(my_func)

 如果您正在使用 Python 3.x,请尝试替换代码中的 inspect.getargspecinspect.signature,以避免此错误。

猜你喜欢

转载自blog.csdn.net/weixin_39842528/article/details/128864416