python - Botocore 错误:HTTP 客户端引发未处理的异常:sys.meta_path 必须是导入挂钩列表
问题描述
我正在运行这个小片段以使用镶木地板将熊猫数据帧上传到 s3。但我得到了错误:
Exception botocore.exceptions.HTTPClientError: HTTPClientError(u'An HTTP Client raised an unhandled exception: sys.meta_path must be a list of import hooks',) in <bound method S3File.__del__ of <S3File /my-bucket-name/parquet/six>> ignored
代码似乎有时可以在 python shell 中工作。在 python shell 上,它不会打印任何错误。
但是当使用 python ./the_script.py 运行时
它打印该错误
from pyarrow import Table
import pyarrow.parquet as pq
import numpy as np
from s3fs import S3File, S3FileSystem
import pandas as pd
fs = S3FileSystem()
bucket_uri = 's3://my-bucket-name/parquet/six'
df = pd.DataFrame({'one': [-1, np.nan, 2.5],
'two': ['foo', 'bar', 'baz'],
'three': [True, False, True]},
index=list('abc'))
table = Table.from_pandas(df.copy())
s3file = S3File(fs, bucket_uri, mode='wb')
pq.write_table(table, s3file)
部分片段是从以下位置复制粘贴的: https ://arrow.apache.org/docs/python/parquet.html?highlight=pyarrow%20parquet%20partition
Python = 2.7.12
botocore = 1.14.9
s3fs = 0.4.2
熊猫 = 0.24.2
pyarrow = 1.0.0
Ubuntu 16.04
谢谢
解决方案
使用了错误(或可能是低级别)功能
而不是 pq.write_table(table, s3file) 做 pq.write_to_dataset(table=table, root_path=bucket_uri, filesystem=fs )
https://www.jitsejan.com/interacting-with-parquet-on-s3.html
推荐阅读
- tensorflow - 该模型将其从预训练模型中知道的所有内容都误认为是我的自定义对象
- function - 接受参数和管道输入的自定义 PowerShell 函数
- css - Vuetify 文本颜色变体
- redis - 如何删除存储在给定 Redis 集中的 Redis 键?
- javascript - 相机反应原生错误“null不是对象”
- wordpress - 更新元数据而不删除先前的值
- flutter - image_picker 插件导致 Android 的构建错误
- linux - 自动下载最新版本的 Slack
- jquery - FullCalendar 上带有设计的工具提示
- c++ - 卡在使用结构向量