Python TypeError: __init__() got an unexpected keyword argument 'multiprocessing_context'
This error occurs when you are trying to pass an unexpected argument to the 'init' method of a class. In this case, it seems like you are trying to pass the argument 'multiprocessing_context' to the 'init' method, but it is not a valid argument for that method.
To fix this error, you can either remove the 'multiprocessing_context' argument from the method call or add it as a valid argument in the class definition.
For example, if you have a class 'MyClass' with an 'init' method like this:
class MyClass:
def __init__(self, arg1, arg2):
# some code here
And you are trying to create an instance of this class like this:
obj = MyClass(arg1_val, arg2_val, multiprocessing_context=multiprocessing.get_context())
You will get the 'TypeError: init() got an unexpected keyword argument 'multiprocessing_context'' error.
To fix it, you can either remove the 'multiprocessing_context' argument:
obj = MyClass(arg1_val, arg2_val)
Or add it as a valid argument in the class definition:
class MyClass:
def __init__(self, arg1, arg2, multiprocessing_context=None):
# some code here
This will allow you to pass the 'multiprocessing_context' argument without getting the error.
原文地址: https://www.cveoy.top/t/topic/lXmz 著作权归作者所有。请勿转载和采集!