Omega2+ openwrt boto3 问题
Omega2+ openwrt boto3 issues
我正在尝试连接我的 onion omega2+ 以将数据有效负载发送到我的 aws dynamodb。
我在家庭用户的 .aws 目录中设置了我的凭据。
完全相同的设置适用于我的 ubuntu 笔记本电脑和我所有的 rpi3,以及我在其他设备上尝试过的所有 venv。
我已经尝试 运行将代码设置为 boto3.resource 和 boto3.client - 我已经尝试 运行将代码设置在不同的 linux 设备上并且它们所有 运行 代码并将有效负载发送到我的 aws dynamodb。
平台之间唯一真正的区别是 openwrt os 上的 omega2+ 运行s,这可能是问题所在?因为这是我能想到的平台之间唯一真正的区别。
import boto3
boto3.set_stream_logger('botocore', level='DEBUG')
dynamodb = boto3.resource('dynamodb')
#dynamodb = boto3.client('dynamodb') # test client output
dynamoTable = dynamodb.Table('test_table')
dynamoTable.put_item(
Item={
'Name': 'Dante',
'Age': '25',
'Location': 'Armidale'
}
)
来自 omega2+ 的输出
2019-09-05 05:31:27,369 botocore.hooks [DEBUG] Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-09-05 05:31:27,687 botocore.hooks [DEBUG] Changing event name from before-call.apigateway to before-call.api-gateway
2019-09-05 05:31:27,721 botocore.hooks [DEBUG] Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-09-05 05:31:27,889 botocore.hooks [DEBUG] Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-09-05 05:31:27,899 botocore.hooks [DEBUG] Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-09-05 05:31:27,939 botocore.hooks [DEBUG] Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-09-05 05:31:27,999 botocore.hooks [DEBUG] Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-09-05 05:31:28,233 botocore.hooks [DEBUG] Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-09-05 05:31:28,244 botocore.hooks [DEBUG] Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-09-05 05:31:28,250 botocore.hooks [DEBUG] Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-09-05 05:31:28,257 botocore.hooks [DEBUG] Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/session.py", line 341, in resource
File "/usr/lib/python3.6/site-packages/botocore/loaders.py", line 132, in _wrapper
data = func(self, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/botocore/loaders.py", line 378, in load_service_model
known_service_names=', '.join(sorted(known_services)))
botocore.exceptions.UnknownServiceError: Unknown service: 'dynamodb'. Valid service names are:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "boto3_aws.py", line 10, in <module>
dynamodb = boto3.resource('dynamodb')
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/__init__.py", line 100, in resource
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/session.py", line 347, in resource
boto3.exceptions.ResourceNotExistsError: The 'dynamodb' resource does not exist.
The available resources are:
-
Consider using a boto3.client('dynamodb') instead of a resource for 'dynamodb'
为简单起见,我在 onion omega2+ 上创建了一个具有 ssh 访问权限的用户。我为用户添加了密码,并为新用户创建了具有正确用户权限的 /home/username。然后我将我的凭据添加到我的用户目录 /home/username/.aws
中的一个隐藏文件夹中
然后我卸载了 boto3 v1.9.219 并使用 pip3 将其降级为 boto3 v1.9.164。
删除有问题的 boto3 版本:
pip3 uninstall boto3==1.9.219
安装 boto3 的降级版本:
pip3 install boto3==1.9.164
保留所有其他文件和凭据信息,上面的脚本连接到我的 aws dynamodb 并添加项目将信息正确地放入我的测试 dynamodb。
您可以使用 pip3 列表或您的 python3 控制台在进行更改之前找出当前安装的 boto3 版本。为确认已安装降级版本,降级后的输出如下。
>>> import boto3
>>> print(boto3.__version__)
1.9.164
>>>
我正在尝试连接我的 onion omega2+ 以将数据有效负载发送到我的 aws dynamodb。
我在家庭用户的 .aws 目录中设置了我的凭据。
完全相同的设置适用于我的 ubuntu 笔记本电脑和我所有的 rpi3,以及我在其他设备上尝试过的所有 venv。
我已经尝试 运行将代码设置为 boto3.resource 和 boto3.client - 我已经尝试 运行将代码设置在不同的 linux 设备上并且它们所有 运行 代码并将有效负载发送到我的 aws dynamodb。
平台之间唯一真正的区别是 openwrt os 上的 omega2+ 运行s,这可能是问题所在?因为这是我能想到的平台之间唯一真正的区别。
import boto3
boto3.set_stream_logger('botocore', level='DEBUG')
dynamodb = boto3.resource('dynamodb')
#dynamodb = boto3.client('dynamodb') # test client output
dynamoTable = dynamodb.Table('test_table')
dynamoTable.put_item(
Item={
'Name': 'Dante',
'Age': '25',
'Location': 'Armidale'
}
)
来自 omega2+ 的输出
2019-09-05 05:31:27,369 botocore.hooks [DEBUG] Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-09-05 05:31:27,687 botocore.hooks [DEBUG] Changing event name from before-call.apigateway to before-call.api-gateway
2019-09-05 05:31:27,721 botocore.hooks [DEBUG] Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-09-05 05:31:27,889 botocore.hooks [DEBUG] Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-09-05 05:31:27,899 botocore.hooks [DEBUG] Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-09-05 05:31:27,939 botocore.hooks [DEBUG] Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-09-05 05:31:27,999 botocore.hooks [DEBUG] Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-09-05 05:31:28,233 botocore.hooks [DEBUG] Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-09-05 05:31:28,244 botocore.hooks [DEBUG] Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-09-05 05:31:28,250 botocore.hooks [DEBUG] Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-09-05 05:31:28,257 botocore.hooks [DEBUG] Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/session.py", line 341, in resource
File "/usr/lib/python3.6/site-packages/botocore/loaders.py", line 132, in _wrapper
data = func(self, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/botocore/loaders.py", line 378, in load_service_model
known_service_names=', '.join(sorted(known_services)))
botocore.exceptions.UnknownServiceError: Unknown service: 'dynamodb'. Valid service names are:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "boto3_aws.py", line 10, in <module>
dynamodb = boto3.resource('dynamodb')
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/__init__.py", line 100, in resource
File "/usr/lib/python3.6/site-packages/boto3-1.9.219-py3.6.egg/boto3/session.py", line 347, in resource
boto3.exceptions.ResourceNotExistsError: The 'dynamodb' resource does not exist.
The available resources are:
-
Consider using a boto3.client('dynamodb') instead of a resource for 'dynamodb'
为简单起见,我在 onion omega2+ 上创建了一个具有 ssh 访问权限的用户。我为用户添加了密码,并为新用户创建了具有正确用户权限的 /home/username。然后我将我的凭据添加到我的用户目录 /home/username/.aws
中的一个隐藏文件夹中然后我卸载了 boto3 v1.9.219 并使用 pip3 将其降级为 boto3 v1.9.164。
删除有问题的 boto3 版本:
pip3 uninstall boto3==1.9.219
安装 boto3 的降级版本:
pip3 install boto3==1.9.164
保留所有其他文件和凭据信息,上面的脚本连接到我的 aws dynamodb 并添加项目将信息正确地放入我的测试 dynamodb。
您可以使用 pip3 列表或您的 python3 控制台在进行更改之前找出当前安装的 boto3 版本。为确认已安装降级版本,降级后的输出如下。
>>> import boto3
>>> print(boto3.__version__)
1.9.164
>>>