Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark 在Python中使用Spark读取S3文件时权限被拒绝_Apache Spark_Amazon S3_Pyspark_Pycharm - Fatal编程技术网

Apache spark 在Python中使用Spark读取S3文件时权限被拒绝

Apache spark 在Python中使用Spark读取S3文件时权限被拒绝,apache-spark,amazon-s3,pyspark,pycharm,Apache Spark,Amazon S3,Pyspark,Pycharm,我正在使用PySpark读取PyCharm中的S3文件。返回了以下错误: py4j.protocol.Py4JJavaError:调用时出错 o26.分区。 org.apache.hadoop.security.AccessControlException:权限被拒绝:s3n://2017/01/22/20/firenam: 代码如下: hadoopConf = sc._jsc.hadoopConfiguration() hadoopConf.set("fs.s3n.awsAccessKeyId

我正在使用PySpark读取PyCharm中的S3文件。返回了以下错误:

py4j.protocol.Py4JJavaError:调用时出错 o26.分区。 org.apache.hadoop.security.AccessControlException:权限被拒绝:s3n://2017/01/22/20/firenam:

代码如下:

hadoopConf = sc._jsc.hadoopConfiguration()
hadoopConf.set("fs.s3n.awsAccessKeyId", "myaccesskey")
hadoopConf.set("fs.s3n.awsSecretAccessKey", "MySecretKey")
temp = sc.textFile("s3n://2017/01/22/filename")
temp.count()
当我使用Boto3从S3和Python下载文件时,它可以成功

将“s3n”更改为“s3a”仍然失败,但出现不同的异常:

返回的错误:java.lang.NoClassDefFoundError: org/apache/hadoop/fs/GlobalStorageStatistics$StorageStatisticsProvider

我还尝试导出以下环境变量:

AWS\u ACCESS\u KEY\u ID=myaccesskey。
AWS_SECRET_ACCESS_KEY=mysecretkey

或者在os.environ中显式添加它们,也会失败

我的环境是:

操作系统:Mac Sierra 10.12.6
火花:2.2.0
Python:3.6.1

我在代码中有以下提交参数

SUBMIT_ARGS = "--master local[*] --jars /ExternalJar/aws-java-sdk-1.7.4.jar,/ExternalJar/hadoop-aws-2.7.3.jar pyspark-shell"
作业直接在PyCharm IDE中运行


有线索吗

看起来您没有在
s3n://2017/01/22/filename
中设置bucket name。有效路径应该是
s3n://bucket\u name/path\u to\u file

看起来您没有在
s3n://2017/01/22/filename
中设置bucket name。有效路径应为
s3n://bucket\u name/path\u to\u file