【问题标题】:How to read .pkl file using python in hdfs如何在 hdfs 中使用 python 读取 .pkl 文件
【发布时间】:2018-05-11 19:06:46
【问题描述】:

我在 IBM 云中使用 Python 3.5.2。我需要在集群环境中运行 pyspark 代码。对于这项工作,我需要使用 python 在 hdfs 中上传 pickle 文件。我看到了comments here

我想上传 terrs.pkl。文件位置在附加的屏幕截图中给出

我正在按照我分享的链接中给出的建议使用以下命令

pickle.load( open( '/user/clsadmin/terrs.pkl', "rb" ) )

但它会抛出错误

No such file or directory: '/user/clsadmin/terrs.pkl'

请参阅随附的屏幕截图。 你能建议我如何使用 python 加载这个 .pkl 文件吗?

【问题讨论】:

  • 当你做 import osos.path.exists('/user/clsadmin/terrs.pkl') 时,你得到的是真还是假?
  • 我说错了
  • 这意味着文件不在该位置,或者您的路径名中有错字。您的泡菜代码调用是正确的。确保您的文件存在于该确切位置。

标签: python hdfs


【解决方案1】:
open_file = open("/user/clsadmin/terrs.pkl", "rb")
data = pickle.load(open_file)
open_file.close()

【讨论】:

  • 在打开文件语句中我也收到错误消息 FileNotFoundError: [Errno 2] No such file or directory: '/user/clsadmin/terrs.pkl'
  • 尝试添加绝对路径。您使用的是什么操作系统?
  • 我正在尝试从我的 Windows 10 连接 IBM Cloud。我正在使用 git 工具连接 IBM Cloud
  • 你的建议和@EmilyJohnson 尝试的有什么区别? pickle.load( open( '/user/clsadmin/terrs.pkl', "rb" ) )open_file = open("/user/clsadmin/terrs.pkl", "rb") data = pickle.load(open_file) 相同
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-04
  • 2016-09-12
  • 1970-01-01
  • 1970-01-01
  • 2021-09-01
相关资源
最近更新 更多