Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

TypeError: can't pickle CompiledFFI objects

未关闭
#397 5 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

@BenRKarl 已经在做这个了。

开始于 2019年6月28日。

评估

这个 Issue 还没有评估数据。

描述

Originally posted this on the group for the AdWords API, but have been redirected here.

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/adwords-api/5pDjjmSuWSE/3zeaZcBCAQAJ

I am trying to programmatically add/update user lists in AdWords, I;ve got to the code so far by following code examples in the docs, but when I try to create a list I get the error TypeError: can't pickle CompiledFFI objects, and I can't work out how to get around it!

from googleads import oauth2

key_file='my_key.json'
application_name = "test"

# Initialize the GoogleRefreshTokenClient using the credentials you received
# in the earlier steps.
oauth2_client = oauth2.GoogleServiceAccountClient(
    key_file, oauth2.GetAPIScope('adwords'))

# Initialize the Ad Manager client.
client = adwords.AdWordsClient(oauth2_client, application_name)

user_list_service = client.GetService('AdwordsUserListService', 'v201809')

user_list = {
      'xsi_type': 'CrmBasedUserList',
      'name': 'Test list #%d' % uuid.uuid4(),
      'description': 'A test list',
      # CRM-based user lists can use a membershipLifeSpan of 10000 to indicate
      # unlimited; otherwise normal values apply.
      'membershipLifeSpan': 30,
      'uploadKeyType': 'CONTACT_INFO'
  }

# Create an operation to add the user list.
operations = [{
    'operator': 'ADD',
    'operand': user_list
}]

result = user_list_service.mutate(operations)

And here is the full error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-43-797ee50d19e7> in <module> 5 }] 6 ----> 7 result = user_list_service.mutate(operations) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\googleads\common.py in MakeSoapRequest(*args) 1380 try: 1381 return soap_service_method( -> 1382 *packed_args, _soapheaders=soap_headers)['body']['rval'] 1383 except zeep.exceptions.Fault as e: 1384 error_list = () ~\AppData\Local\Continuum\anaconda3\lib\site-packages\zeep\proxy.py in __call__(self, *args, **kwargs) 40 return self._proxy._binding.send( 41 self._proxy._client, self._proxy._binding_options, ---> 42 self._op_name, args, kwargs) 43 44 ~\AppData\Local\Continuum\anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in send(self, client, options, operation, args, kwargs) 119 operation, args, kwargs, 120 client=client, --> 121 options=options) 122 123 response = client.transport.post_xml( ~\AppData\Local\Continuum\anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in _create(self, operation, args, kwargs, client, options) 66 67 # Create the SOAP envelope ---> 68 serialized = operation_obj.create(*args, **kwargs) 69 self._set_http_headers(serialized, operation_obj) 70 ~\AppData\Local\Continuum\anaconda3\lib\site-packages\zeep\wsdl\definitions.py in create(self, *args, **kwargs) 198 199 def create(self, *args, **kwargs): --> 200 return self.input.serialize(*args, **kwargs) 201 202 def process_reply(self, envelope): ~\AppData\Local\Continuum\anaconda3\lib\site-packages\zeep\wsdl\messages\soap.py in serialize(self, *args, **kwargs) 61 # Create the soap:header element 62 headers_value = kwargs.pop('_soapheaders', None) ---> 63 header = self._serialize_header(headers_value, nsmap) 64 if header is not None: 65 envelope.append(header) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\zeep\wsdl\messages\soap.py in _serialize_header(self, headers_value, nsmap) 322 return 323 --> 324 headers_value = copy.deepcopy(headers_value) 325 326 soap = ElementMaker(namespace=self.nsmap['soap-env'], nsmap=nsmap) ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 148 copier = _deepcopy_dispatch.get(cls) 149 if copier: --> 150 y = copier(x, memo) 151 else: 152 try: ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _deepcopy_dict(x, memo, deepcopy) 238 memo[id(x)] = y 239 for key, value in x.items(): --> 240 y[deepcopy(key, memo)] = deepcopy(value, memo) 241 return y 242 d[dict] = _deepcopy_dict ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 159 copier = getattr(x, "__deepcopy__", None) 160 if copier: --> 161 y = copier(memo) 162 else: 163 reductor = dispatch_table.get(cls) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\zeep\xsd\valueobjects.py in __deepcopy__(self, memo) 144 def __deepcopy__(self, memo): 145 new = type(self)() --> 146 new.__values__ = copy.deepcopy(self.__values__) 147 for attr, value in self.__dict__.items(): 148 if attr != '__values__': ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 178 y = x 179 else: --> 180 y = _reconstruct(x, memo, *rv) 181 182 # If is its own copy, don't memoize. ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 304 for key, value in dictiter: 305 key = deepcopy(key, memo) --> 306 value = deepcopy(value, memo) 307 y[key] = value 308 else: ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 178 y = x 179 else: --> 180 y = _reconstruct(x, memo, *rv) 181 182 # If is its own copy, don't memoize. ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 278 if state is not None: 279 if deep: --> 280 state = deepcopy(state, memo) 281 if hasattr(y, '__setstate__'): 282 y.__setstate__(state) ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 148 copier = _deepcopy_dispatch.get(cls) 149 if copier: --> 150 y = copier(x, memo) 151 else: 152 try: ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _deepcopy_dict(x, memo, deepcopy) 238 memo[id(x)] = y 239 for key, value in x.items(): --> 240 y[deepcopy(key, memo)] = deepcopy(value, memo) 241 return y 242 d[dict] = _deepcopy_dict ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 178 y = x 179 else: --> 180 y = _reconstruct(x, memo, *rv) 181 182 # If is its own copy, don't memoize. ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 278 if state is not None: 279 if deep: --> 280 state = deepcopy(state, memo) 281 if hasattr(y, '__setstate__'): 282 y.__setstate__(state) ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 148 copier = _deepcopy_dispatch.get(cls) 149 if copier: --> 150 y = copier(x, memo) 151 else: 152 try: ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _deepcopy_dict(x, memo, deepcopy) 238 memo[id(x)] = y 239 for key, value in x.items(): --> 240 y[deepcopy(key, memo)] = deepcopy(value, memo) 241 return y 242 d[dict] = _deepcopy_dict ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 178 y = x 179 else: --> 180 y = _reconstruct(x, memo, *rv) 181 182 # If is its own copy, don't memoize. ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 278 if state is not None: 279 if deep: --> 280 state = deepcopy(state, memo) 281 if hasattr(y, '__setstate__'): 282 y.__setstate__(state) ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 148 copier = _deepcopy_dispatch.get(cls) 149 if copier: --> 150 y = copier(x, memo) 151 else: 152 try: ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _deepcopy_dict(x, memo, deepcopy) 238 memo[id(x)] = y 239 for key, value in x.items(): --> 240 y[deepcopy(key, memo)] = deepcopy(value, memo) 241 return y 242 d[dict] = _deepcopy_dict ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 178 y = x 179 else: --> 180 y = _reconstruct(x, memo, *rv) 181 182 # If is its own copy, don't memoize. ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 278 if state is not None: 279 if deep: --> 280 state = deepcopy(state, memo) 281 if hasattr(y, '__setstate__'): 282 y.__setstate__(state) ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 148 copier = _deepcopy_dispatch.get(cls) 149 if copier: --> 150 y = copier(x, memo) 151 else: 152 try: ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _deepcopy_dict(x, memo, deepcopy) 238 memo[id(x)] = y 239 for key, value in x.items(): --> 240 y[deepcopy(key, memo)] = deepcopy(value, memo) 241 return y 242 d[dict] = _deepcopy_dict ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 178 y = x 179 else: --> 180 y = _reconstruct(x, memo, *rv) 181 182 # If is its own copy, don't memoize. ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy) 278 if state is not None: 279 if deep: --> 280 state = deepcopy(state, memo) 281 if hasattr(y, '__setstate__'): 282 y.__setstate__(state) ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 148 copier = _deepcopy_dispatch.get(cls) 149 if copier: --> 150 y = copier(x, memo) 151 else: 152 try: ~\AppData\Local\Continuum\anaconda3\lib\copy.py in _deepcopy_dict(x, memo, deepcopy) 238 memo[id(x)] = y 239 for key, value in x.items(): --> 240 y[deepcopy(key, memo)] = deepcopy(value, memo) 241 return y 242 d[dict] = _deepcopy_dict ~\AppData\Local\Continuum\anaconda3\lib\copy.py in deepcopy(x, memo, _nil) 167 reductor = getattr(x, "__reduce_ex__", None) 168 if reductor: --> 169 rv = reductor(4) 170 else: 171 reductor = getattr(x, "__reduce__", None) TypeError: can't pickle CompiledFFI objects

主要语言
Python
星标
749
派生
967
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleads/googleads-python-lib 的其他 Issue

查看 googleads/googleads-python-lib 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。