Python 设置禁用路径长度限制的优缺点?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51624449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Setup Disabling Path Length Limit Pros and Cons?
提问by Qwerty Qwerts
I recently installed python 3.7 and at the end of the download there is the option to Disable Path Length Limit. I don't know whether or not I should do this. What are the pros and cons of doing it. Just from the sound of it you should always disable it.
我最近安装了 python 3.7,在下载结束时有禁用路径长度限制的选项。我不知道我是否应该这样做。这样做有什么好处和坏处。仅从它的声音来看,您应该始终禁用它。
回答by khan
I recommend selecting that option and thereby removing the path length limit. It will potentially save you time in future on debugging an avoidable issue.
我建议选择该选项,从而消除路径长度限制。它可能会节省您将来调试可避免问题的时间。
Here is an anecdote of how I came to know about it:
这是我是如何知道它的一个轶事:
During the compilation of my program (C# code on a Windows machine), I started getting the following error:
在编译我的程序(Windows 机器上的 C# 代码)期间,我开始收到以下错误:
error MSB3541: Files has invalid value "long\path\filename". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
This error was not allowing me to build my project and the only apparent solution to this issue was to shorten my path/file names. Turns out that this bug is a built-in limitation in NTFS (Window's File System): Why does the 260 character path length limit exist in Windows?
这个错误不允许我构建我的项目,这个问题的唯一明显解决方案是缩短我的路径/文件名。原来这个错误是 NTFS(Windows 文件系统)中的一个内置限制:为什么 Windows 中存在 260 个字符的路径长度限制?
After a couple of decades with the limitation built into the NTFS file system, it has finally been fixed (Unix based system did not have it) in Windows 10 (https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation), but it is not enabled automatically, and needs registry (or group policy) settings to do this. The Python option allows you to disable it for Python libraries, saving you a lot of headache.
在 NTFS 文件系统内置限制几十年后,它终于在 Windows 10 中得到修复(基于 Unix 的系统没有它)(https://docs.microsoft.com/en-us/windows/desktop /FileIO/naming-a-file#maximum-path-length-limitation),但它不会自动启用,并且需要注册表(或组策略)设置来执行此操作。Python 选项允许您为 Python 库禁用它,从而为您省去很多麻烦。
Do note that enabling this option will,
请注意,启用此选项将,
a) break compatibility of your programs on systems using older versions of Windows 10 and lower, when using long file/directory names and paths.
a) 当使用长文件/目录名称和路径时,会破坏您的程序在使用旧版 Windows 10 及更低版本的系统上的兼容性。
b) break programs on Windows 10 machines not having this option enabled, when using long file/directory names and paths.
b) 使用长文件/目录名称和路径时,在未启用此选项的 Windows 10 机器上中断程序。