用于MS Windows的命令行实用程序,用于保持Windows路径变量整洁和简短。
pywinpath的Python项目详细描述
pywinpath是编辑%path%环境的交互式命令行工具 Windows 7上的变量。 用于在Windows 10之前管理%path%内容的板载工具 几乎不存在,很容易导致杂乱的%PATH %。 如果路径超过特定限制,windows将自动忽略 无法找到超过最大长度和可执行文件的条目。
当面对%path%时,pywinpath试图让您保持清醒。有很多免费工具 但是,要编辑%path%,我在python中找不到好的路径。 windows 10有自己的gui来操作%path%,我还没有看到。
在Windows上,将生成%path%的内容 来自两个注册表值:系统范围路径中的条目,后跟 用户特定路径中的条目。
- User path: ^{tt1}$
- System path: ^{tt2}$
pywinpath允许您操作这两个注册表值并执行 一些额外的技巧,请参见下面列出的特性。
使用python 3.5在windows 7(en-us)上开发和测试,所以不要 希望它能在python 2或其他系统上工作。请告诉我 如果它在其他组合中对你有用,如果没有打开一个问题 Github,给我一个补丁或者请求。
安装
pip install pywinpath
或者如果您想看到一些彩色输出(这将安装colorama):
pip install pywinpath[color]
功能
- Warns you of a too long %PATH% on Windows 7
- Normalization of PATH entries followed by …
- Deduplication of system and user PATH variables
- Purge non-existent directories from PATH variables
- Shortening of PATH variables via junctions, e.g. C:Program Files… gets C:prg…
- Insert entries at the beginning of the PATH
待办事项
- Add possibility to call with arguments instead of as interactive menu
- Move entries up and down and between sys and user path (only after dedup?)
- Handle variable expansions in PATH definitions such as %USERPROFILE%
- Automatically identify efficient sub-paths for shortening via junctions
- More tests
- Test on other Windows-Python3 combinations than Windows 7 - Python 3.5
注释
- With Git for Windows installed, the following command should display a more readable PATH listing on the console: ^{tt5}$
- Junctions work for PATH shortening, also accross local drives:
- >mklink /J C:prog(x86) “C:Program Files (x86)”
- >set PATH=c:prog(x86)Notepad++;%PATH%
- Notepad++.exe is found.
- Junctions can be deleted by rmdir, the target dir is left untouched.
由路径过长的Python错误引起:
D:\proj>activate Deactivating environment "C:\Users\***\AppData\Local\Continuum\Anaconda3"... Activating environment "C:\Users\***\AppData\Local\Continuum\Anaconda3"... The input line is too long. "PATH_NO_SCRIPTS=C:\Users\***\AppData\Local\Continuum\Anaconda3;[...]"
一些链接:
- Viewed about 40k times: http://superuser.com/questions/297947/is-there-a-convenient-way-to-edit-path-in-windows-7
- Another PATH minipulation tool for the command line http://www.p-nand-q.com/download/gtools/pathed.html
- http://stackoverflow.com/questions/34818282/anaconda-prompt-loading-error-the-input-line-is-too-long
- http://stackoverflow.com/questions/19287379/how-do-i-add-to-the-windows-path-variable-using-setx-having-weird-problems
- https://software.intel.com/en-us/articles/limitation-to-the-length-of-the-system-path-variable
- http://betanews.com/2015/11/23/windows-10-finally-adds-a-new-path-editor/