程序报错 2021-07-15 14:46 采纳率: 80%
浏览 774
已采纳

python读取和存储hdf5文件无法使用中文路径

代码:

df.to_hdf('F:\中文路径\hdf5_file.h5',key='file1',mode='w')

报错内容:
Traceback (most recent call last):
File "F:/代码/code.py", line 48, in
hdf5_data.to_hdf('F:\中文路径\hdf5_file.h5',key='file1',mode='w')
File "E:\python\lib\site-packages\pandas\core\generic.py", line 2606, in to_hdf
pytables.to_hdf(
File "E:\python\lib\site-packages\pandas\io\pytables.py", line 277, in to_hdf
with HDFStore(
File "E:\python\lib\site-packages\pandas\io\pytables.py", line 561, in init
self.open(mode=mode, **kwargs)
File "E:\python\lib\site-packages\pandas\io\pytables.py", line 710, in open
self._handle = tables.open_file(self._path, self._mode, **kwargs)
File "E:\python\lib\site-packages\tables\file.py", line 315, in open_file
return File(filename, mode, title, root_uep, filters, **kwargs)
File "E:\python\lib\site-packages\tables\file.py", line 778, in init
self._g_new(filename, mode, **params)
File "tables/hdf5extension.pyx", line 492, in tables.hdf5extension.File._g_new
tables.exceptions.HDF5ExtError: HDF5 error back trace

File "C:\ci\hdf5_1545244154871\work\src\H5F.c", line 444, in H5Fcreate
unable to create file
File "C:\ci\hdf5_1545244154871\work\src\H5Fint.c", line 1364, in H5F__create
unable to open file
File "C:\ci\hdf5_1545244154871\work\src\H5Fint.c", line 1557, in H5F_open
unable to open file: time = Thu Jul 15 14:38:30 2021
, name = 'F:\中文路径\hdf5_file.h5', tent_flags = 13
File "C:\ci\hdf5_1545244154871\work\src\H5FD.c", line 734, in H5FD_open
open failed
File "C:\ci\hdf5_1545244154871\work\src\H5FDsec2.c", line 346, in H5FD_sec2_open
unable to open file: name = 'F:\中文路径\hdf5_file.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 302

End of HDF5 error back trace

Unable to open/create file 'F:\中文路径\hdf5_file.h5'

  • 写回答

3条回答 默认 最新

  • 天元浪子 Python领域优质创作者 2021-07-15 17:35
    关注

    何必要在一棵树上吊死呢?试试h5py,这才是读写hdf文件的正确方式。

    >>> import h5py
    >>> with h5py.File(r'D:\数据文件\hdf5demo.h5', 'r') as fp:
        lons = fp['lons'][()]
    
        
    >>> lons.shape
    (361, 721)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已采纳回答 7月15日
  • 创建了问题 7月15日

悬赏问题

  • ¥15 使用wpf制作打砖块游戏时遇到的一个Bug
  • ¥15 qrCodeDetector.detectAndDecode
  • ¥15 海洋可控源和大地电磁一维联合反演
  • ¥15 MFC多文档程序获取视图指针问题
  • ¥20 解体如何编写程序还有运行结果截图
  • ¥15 如何把matlabR2023遗传算法工具箱里面的各类选项对应的代码调出来呢?
  • ¥30 MDIGetActive() 获取活动view
  • ¥15 有数据,如何安装使用CLIP模型检索图片
  • ¥15 lingo代码报错无法运行,如何解决,如果能解决请提供能够运行的lingo代码
  • ¥100 读取 IMU BNO080 数据