googleads / googleads/googleads-python-lib

TypeError: can't pickle CompiledFFI objects

オープン
#397 コメント 5 件 リアクション 1 件 担当者 1 名 GitHub で見る

@BenRKarl がすでに取り組んでいます。

2019年6月28日 から。

主要言語
Python
スター
749
フォーク
967
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。