I have this Python code:
cos = ibm_boto3.client('s3',
verify=False,
ibm_api_key_id=api_key,
ibm_service_instance_id=service_instance_id,
ibm_auth_endpoint=auth_endpoint,
config=Config(signature_version='oauth'),
endpoint_url=service_endpoint)
response = cos.list_buckets(IBMServiceInstanceId=service_instance_id)
print('Response %s' % response)
It gives me this error(Note. Some of the trace has been removed):
Traceback (most recent call last):
File "/venv/lib/python3.7/site-packages/ibm_botocore/model.py", line 588, in resolve_shape_ref
shape_name = member_traits.pop('shape')
KeyError: 'shape'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "listing.py", line 21, in <module>
response2 = cos.list_buckets(IBMServiceInstanceId=service_instance_id)
File "/venv/lib/python3.7/site-packages/ibm_botocore/model.py", line 187, in members
shape_members[name] = self._resolve_shape_ref(shape_ref)
File "/venv/lib/python3.7/site-packages/ibm_botocore/model.py", line 164, in _resolve_shape_ref
return self._shape_resolver.resolve_shape_ref(shape_ref)
File "/venv/lib/python3.7/site-packages/ibm_botocore/model.py", line 591, in resolve_shape_ref
"Invalid model, missing shape reference: %s" % shape_ref)
ibm_botocore.model.InvalidShapeReferenceError: Invalid model, missing shape reference: OrderedDict([('location', 'header'), ('locationName', 'Ibm-Service-Instance-Id')])
I checked the shape and the list_buckets seems to be there. I'm not sure what else I need to check. Can anybody advice where the issue might be?
list_buckets wasn't configured correctly on the device. Once configured I was able to perform the operation.
Related
I am working on a channels attribution project in Python. I use the python library "ChannelAttribution". When I followed the instruction from the official documentation and tried to use the built-in function "markov_model_local_api", it kept throwing an error. Then I tried to run the sample codes from https://channelattribution.io/pdf/ChannelAttributionWhitePaper.pdf:
from ChannelAttribution import *
#Download data
Data = pd.read_csv("https://channelattribution.io/csv/Data.csv",sep=";")
#Generate token
generate_token(email="my_email", job="my_job", company="my_institution")
token = 'my_token'
#Train
res=markov_model_local_api(token, Data, var_path="path", var_conv="total_conversions",var_value="total_conversion_value", var_null="total_null", order=1, sep=">")
It throws these errors below:
Exception ignored in: <function Connection.__del__ at 0x7fba45595670>
Traceback (most recent call last):
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 1013, in __del__
self.close()
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 784, in close
if self._sftp_live:
AttributeError: 'Connection' object has no attribute '_sftp_live'
Traceback (most recent call last):
File "src/cypack/ChannelAttribution.pyx", line 1188, in ChannelAttribution.markov_model_local_api
File "src/cypack/ChannelAttribution.pyx", line 894, in ChannelAttribution.__f_initialize_connection
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 132, in __init__
self._tconnect['hostkey'] = self._cnopts.get_hostkey(host)
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 71, in get_hostkey
raise SSHException("No hostkey for host %s found." % host)
SSHException: No hostkey for host 13.58.174.83 found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/li/Downloads/untitled0.py", line 18, in <module>
res=markov_model_local_api(token, Data, var_path="path", var_conv="total_conversions", var_value="total_conversion_value", var_null="total_null", order=1, sep=">")
File "src/cypack/ChannelAttribution.pyx", line 1248, in ChannelAttribution.markov_model_local_api
UnboundLocalError: local variable 'filename' referenced before assignment
How can I fix all errors and exceptions?
I have two issues:
I'm calling G-Ads API to bulk remove ads (code)
for error_detail in error_details:
# Retrieve an instance of the google_ads_failure class from the client
failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")
# Parse the string into a google_ads_failure message instance.
# To access class-only methods on the message we retrieve its type.
google_ads_failure = type(failure_message)
failure_object = google_ads_failure.deserialize(error_detail.value)
for error in failure_object.errors:
# Construct and print a string that details which element in
# the above ad_group_operations list failed (by index number)
# as well as the error message and error code.
print("A partial failure at index "
f"{error.location.field_path_elements[0].index} occurred "
f"\nError message: {error.message}\nError code: "
f"{error.error_code}")
index_array.append(error.location.field_path_elements[0].index)
error_array.append({"error_message": error.message, "error_code": error.error_code})
I get a partial error
And the code fails to parse it (taken form the official website)
My terminal shows:
Partial failures occurred. Details will be shown below.
Traceback (most recent call last):
File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\client.py", line 426, in get_type
message_class = getattr(type_classes, name)
File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\v8\__init__.py", line 1753, in __getattr__
raise AttributeError(f"unknown type {name!r}.")
AttributeError: unknown type 'google_ads_failure'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\projects\bowling\src\main.py", line 535, in <module>
main(args.top_id)
File "D:\projects\bowling\src\main.py", line 141, in main
removed_ads_count = remove_disapproved_ads_for_account(account)
File "D:\projects\bowling\src\main.py", line 206, in remove_disapproved_ads_for_account
remove_ads(ad_removal_operations, ads_to_remove_json, account_id)
File "D:\projects\bowling\src\main.py", line 300, in remove_ads
index_array, error_array = _print_results(response_chunk)
File "D:\projects\bowling\src\main.py", line 439, in _print_results
failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")
File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\client.py", line 428, in get_type
raise ValueError(
ValueError: Specified type 'google_ads_failure' does not exist in Google Ads API v8
failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")
I think this should be -
failure_message = gAdsServiceWrapper.client.get_type("GoogleAdsFailure")
I'm trying to get this, https://github.com/joaquinlpereyra/twitterImgBot, to work
and it works and it seems ok.
But after some hours, it stops working and this error comes up:
*python3 twitterbot.py
Traceback (most recent call last):
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 118, in build_path
value = quote(self.session.params[name])
KeyError: 'id'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "twitterbot.py", line 209, in <module>
main()
File "twitterbot.py", line 200, in main
orders()
File "twitterbot.py", line 118, in orders
timeline.delete_tweet_by_id(tweet.in_reply_to_status_id, api)
File "/home/user/Skrivebord/twitterboot/lo/bot/timeline.py", line 12, in delete_tweet_by_id
api.destroy_status(id_to_delete)
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 245, in _call
method = APIMethod(args, kwargs)
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 71, in __init__
self.build_path()
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 120, in build_path
raise TweepError('No parameter value found for path variable: %s' % name)
tweepy.error.TweepError: No parameter value found for path variable: id*
It seems like the Python has some problem because if I make a new install on a another PC it works for some hours and then stops.
Strange.
This is likely because tweet is not in reply to a status, so has an in_reply_to_status_id attribute that's None, so API.destroy_status is called with an id of None.
I have the following code:
s = Search(using=Elasticsearch('http://user:passwd#ipaddress'), index="myindex")
q = Q("multi_match", query='some query', fields=['_all'])
s = s.query(q)
response = s.execute()
print('Total %d hits found.' % response.hits.total)
for hit in response:
print(hit.title)
And I get the error:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/elasticsearch_dsl/utils.py", line 102, in __getattr__
return _wrap(self._d_[attr_name])
KeyError: 'title'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "FindImage.py", line 89, in <module>
main(args.image_file)
File "FindImage.py", line 82, in main
query_db([1], [2])
File "FindImage.py", line 77, in query_db
print(hit.title)
File "/usr/local/lib/python3.5/dist-packages/elasticsearch_dsl/utils.py", line 105, in __getattr__
'%r object has no attribute %r' % (self.__class__.__name__, attr_name))
AttributeError: 'Result' object has no attribute 'title'
However that is in direct contradiction to what the docs state:
Docs
What am I doing wrong? How can I correctly extract the hits and my values from the response?
EDIT
Also the response object ist supposed to have a method "toDict" but when I try to call it I again get an AttributeError.
For the "toDict" question, response.to_dict() works for me. Not sure if this behaviour is the same across lib versions.
Apparently the ".title" references an actual column in their example.
When I used hit.doc.FIRSTTAG, FIRSTTAG being a column in MY NoSQL-db it worked.
Still does not explain the missing method, but I am happy with it for now.
So to anyone having the same problem:
Use your own columns names when evaluating the response object e.g. in my example:
for hit in response:
print(hit.doc.FIRSTTAG)
Regarding this thread : http://goo.gl/uEyFua
I am experiencing a quite similar issue with the following code, trying to import a large Graph :
for (edge_id) in cursorSQL:
L.add((edge_id[2], str(edge_id[1])))
g = igraph.Graph.TupleList(L)
I get the following errors :
Traceback (most recent call last):
File "C.py", line 707, in __getitem__ return self._ids[item]
KeyError: '184840900'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
g = igraph.Graph.TupleList(L)
File "C:\Python34\lib\site-packages\igraph\__init__.py", line 2473, in TupleList
edge_list.append((idgen[item[0]], idgen[item[1]]))
File "C:\Python34\lib\site-packages\igraph\datatypes.py", line 709, in __getitem__
self._ids[item] = next(self._generator)
MemoryError
Just to make it clear. This code works perfectly until number of edges is too large (~4millions.)
Thanks.
Switched to python-64bits, and problem is now solved.
Problem was the 2GB-per-process limit in win7 for python-32bits.