Windows操作系统无法打开适用于Linux的文件名
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows操作系统无法打开适用于Linux的文件名相关的知识,希望对你有一定的参考价值。
我正在Linux上开发一个小型Python应用程序,其中代码在系统Python3和Anaconda Python3解释器上运行良好。但是,当我在Anaconda / Windows上运行它时,我得到了这个回溯:
Traceback (most recent call last):
File "C:Users<redacted>AppDataLocalContinuumanaconda3lib kinter\__init__.py"
, line 1699, in __call__
return self.func(*args)
File "./dataView.py", line 312, in doChop
self.DA.chop()
File "C:Users<redacted>DataAnalyser.py", line 212, in chop
self.df.to_hdf( filename, mode='w', key=hdfKey, data_columns = view )
File "C:Users<redacted>AppDataLocalContinuumanaconda3libsite-packagespandas
coregeneric.py", line 1471, in to_hdf
return pytables.to_hdf(path_or_buf, key, self, **kwargs)
File "C:Users<redacted>AppDataLocalContinuumanaconda3libsite-packagespandas
iopytables.py", line 280, in to_hdf
complib=complib) as store:
File "C:Users<redacted>AppDataLocalContinuumanaconda3libsite-packagespandas
iopytables.py", line 467, in __init__
self.open(mode=mode, **kwargs)
File "C:Users<redacted>AppDataLocalContinuumanaconda3libsite-packagespandas
iopytables.py", line 580, in open
self._handle = tables.open_file(self._path, self._mode, **kwargs)
File "C:Users<redacted>AppDataLocalContinuumanaconda3libsite-packages ables
file.py", line 320, in open_file
return File(filename, mode, title, root_uep, filters, **kwargs)
File "C:Users<redacted>AppDataLocalContinuumanaconda3libsite-packages ables
file.py", line 784, in __init__
self._g_new(filename, mode, **params)
File "tableshdf5extension.pyx", line 487, in tables.hdf5extension.File._g_new
tables.exceptions.HDF5ExtError: HDF5 error back trace
File "C:Usersuildermc3conda-bldhdf5_1506030377716worksrcH5F.c", line
491, in H5Fcreate
unable to create file
File "C:Usersuildermc3conda-bldhdf5_1506030377716worksrcH5Fint.c", li
ne 1247, in H5F_open
unable to open file: time = Wed Feb 28 18:26:31 2018
, name = 'chop_x:0:49.hdf5', tent_flags = 13
File "C:Usersuildermc3conda-bldhdf5_1506030377716worksrcH5FD.c", line
809, in H5FD_open
open failed
File "C:Usersuildermc3conda-bldhdf5_1506030377716worksrcH5FDsec2.c",
line 346, in H5FD_sec2_open
unable to open file: name = 'chop_x:0:49.hdf5', errno = 22, error message =
'Invalid argument', flags = 13, o_flags = 302
End of HDF5 error back trace
Unable to open/create file 'chop_x:0:49.hdf5'
我尝试在Anaconda / Win ipython3中手动写入一个完全相同名称的文件,这也很好。我也尝试将名称更改为一个简单的字符串,它起作用,表明我用str.format()构造的文件名值确实有问题。另一方面,当我做df.to_hdf('chop_x:0:49.hdf5', 'w', 'chop')
它工作正常。我怎样才能看到我传递的参数有什么问题?你认为这是另一个参数的问题吗?
不同的操作系统对路径和文件名中允许的字符有不同的限制。
尝试在Windows资源管理器中使用:
创建文件名,您就会明白为什么它不起作用。
Naming Files, Paths, and Namespaces
弃权使用:
< (less than) > (greater than) : (colon) " (double quote) / (forward slash) (backslash) | (vertical bar or pipe) ? (question mark) * (asterisk)
整数值为零,有时也称为ASCII NUL字符。整数表示形式在1到31范围内的字符,但允许使用这些字符的备用数据流除外。
(摘自上面链接的内容,还有更多内容,请阅读。)
以上是关于Windows操作系统无法打开适用于Linux的文件名的主要内容,如果未能解决你的问题,请参考以下文章
适用于 Linux 的 Windows 子系统安装指南 (Windows 10) (微软官方文档)
WSL(Windows Subsystem for Linux) 适用于Linux的Windows子系统