Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/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
Python FileNotFoundException:File File:/path/to/File/in.txt不存在,或者运行Flink的用户没有足够的权限访问它_Python_Apache Flink - Fatal编程技术网

Python FileNotFoundException:File File:/path/to/File/in.txt不存在,或者运行Flink的用户没有足够的权限访问它

Python FileNotFoundException:File File:/path/to/File/in.txt不存在,或者运行Flink的用户没有足够的权限访问它,python,apache-flink,Python,Apache Flink,我正在尝试使用flink和python批处理api测试Wordcount经典示例。 我的问题是,在将数据源从env.from_elements()修改为env.read_text()后(对于更大的测试用例),会发生错误。下面的代码描述了我的实现 [...] if __name__ == "__main__": env = get_environment() input_file = 'file:///workfile.txt/' if len(sys.argv) != 1 and len(sy

我正在尝试使用flink和python批处理api测试Wordcount经典示例。 我的问题是,在将数据源从env.from_elements()修改为env.read_text()后(对于更大的测试用例),会发生错误。下面的代码描述了我的实现

[...]
if __name__ == "__main__":
env = get_environment()
input_file = 'file:///workfile.txt/'

if len(sys.argv) != 1 and len(sys.argv) != 3:
    sys.exit("Usage: ./bin/pyflink.sh WordCount[ - <text path> <result path>]")

if len(sys.argv) == 3:
    data = env.read_text(sys.argv[1])
else:
    #data = env.from_elements("hello","world","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello","car","tree","data","hello")
    data = env.read_text(input_file)

result = data \
    .flat_map(Tokenizer()) \
    .group_by(1) \
    .reduce_group(Adder(), combinable=True) \

if len(sys.argv) == 3:
    result.write_csv(sys.argv[2])
else:
    result.output()
[...]
[…]
如果名称=“\uuuuu main\uuuuuuuu”:
env=get_environment()
输入文件file:///workfile.txt/'
如果len(sys.argv)!=1和len(系统argv)!=三:
sys.exit(“用法:./bin/pyflink.sh WordCount[-]”)
如果len(sys.argv)==3:
数据=环境读取文本(sys.argv[1])
其他:
#数据=环境元素(“hello”、“world”、“hello”、“car”、“tree”、“data”、“hello”、“car”、“tree”、“data”、“hello”、“car”、“tree”、“data”、“hello”、“car”、“tree”、“data”、“data”、“hello”、“car”、“tree”、“data”、“hello”、“car”、“tree”、“data”、“car”、“tree”、“data”、“hello”、“car”、“tree”、“data”、“car”、“data”、“hello”、“car”、“car”、“tree”、“tree”、“data”、“car”、“car”、“tree”、“tree”、“data”等“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“数据”、“你好”、“汽车”、“树”、“数据”、“你好”、“汽车”、“数据”、“你好”、“汽车”、“数据”、“你好”、“汽车”,“树”,“数据”,“你好”,“汽车”,“树”,“数据”,“你好”,“汽车”,“树”,“数据”,“你好”,“汽车”,“树”,“数据”,“你好”,“汽车”,“树”,“数据”,“你好”,“汽车”,“树”,“数据”,“你好”,“汽车”,“树”,“数据”,“你好”,“汽车”,“树”,“数据”,“你好”)
数据=环境读取文本(输入文件)
结果=数据\
.flat_映射(标记器())\
.分组人(1)\
.reduce_组(Adder(),combinable=True)\
如果len(sys.argv)==3:
result.write_csv(sys.argv[2])
其他:
结果.输出()
[...]
执行上述代码时,会抛出一个文件权限错误。更具体地说,以下消息

原因:org.apache.flink.runtime.JobException:创建输入拆分导致错误:File File:/workfile.txt不存在,或者运行flink的用户(“用户”)没有足够的权限访问它

PS:已搜索解决方案,但找不到任何内容。如果这个问题已经解决,我将非常感谢重定向。

我假设“workfile.txt”应该是一个相对路径。但是,您不能有带有方案的相对文件(“文件://”)

请提供完整的绝对路径,它应该可以工作


请注意,相对路径通常不适用于Python API,因为我们在临时位置执行脚本。

能否共享您的
get\u环境
?环境不包含任何信息,它只是一个API。感谢您的评论eah,绝对路径就是解决方案。但出于某种原因,我认为绝对路径就是我称之为flink的工作经理的路径。然后我尝试了从/home/to/flink/txt/path的路径,结果很好。