本文介绍了如何从 Sublime Text 3 Python 构建错误中删除 Windows PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Sublime Text 3(win8.1 64 位)上使用 Python 3.当我编写一些代码然后构建时,如果出现错误,Windows PATH 将显示为错误的一部分.

I am using Python 3 on Sublime Text 3 (win8.1 64bit). When I write some code and then build, if there is an error, the Windows PATH is displayed as part of the error.

出现错误时如何在 Sublime Text 3 输出上删除 Windows PATH?

How do I remove the Windows PATH on Sublime Text 3 output when there is an error?

我不会删除==>我要删除.

I wont to remove ==> I want to erase.

推荐答案

可以通过注释掉 Packages/Default/exec.py 中的四行特定行来更改此行为,这是系统文件默认运行构建系统.

This behavior can be changed by commenting out four specific lines in Packages/Default/exec.py, which is the system file that runs build systems by default.

首先,您需要安装 PackageResourceViewer 来自包控制.接下来,使用 打开命令面板并输入 prv 调出 PackageResourceViewer 选项.选择 PackageResourceViewer: Open Resource,然后是 Default,然后是 exec.py.您现在可以点击 来清除命令面板.

First, you'll need to install PackageResourceViewer from Package Control. Next, open the Command Palette with and type in prv to bring up the PackageResourceViewer options. Select PackageResourceViewer: Open Resource, then Default, then exec.py. You can now hit to clear the Command Palette.

在打开的文件中,向下滚动到大约第 212 行,专门查找此代码块:

In the open file, scroll down to approximately line 212, looking specifically for this code block:

if "PATH" in merged_env:
    self.debug_text += "[path: " + str(merged_env["PATH"]) + "]"
else:
    self.debug_text += "[path: " + str(os.environ["PATH"]) + "]"

选择所有 4 行,然后按 将它们注释掉.最后,点击 保存文件.

Select all 4 lines, then comment them out by hitting . Finally, hit to save the file.

这将在您的 Packages 目录中创建一个新的 Default 文件夹(通过选择 Preferences -> Browse Packages...) 和 exec.py 在里面,并将覆盖存储在 Default.sublime-package 中的原始文件,该文件存储在其他地方,在 Sublime 的安装中目录.如果您希望再次打印完整的 PATH,只需打开 Packages/Default/exec.py 并取消注释您之前注释的行,然后保存文件.

This will create a new Default folder in your Packages directory (the one opened by selecting Preferences -> Browse Packages...) with exec.py inside, and will override the original file stored in Default.sublime-package, which is stored elsewhere, in Sublime's installation directory. If at any time you wish to have the full PATH printed again, simply open Packages/Default/exec.py and uncomment the lines you commented before, then save the file.

我还建议删除 exec.py 并重新运行上述过程每次升级 Sublime,因为在新版本是构建系统其他部分正常工作的关键.

I would also recommend deleting exec.py and re-running through the procedure above every time you upgrade Sublime, as there may be vital changes to this file in the new release that are key for other parts of the build systems to work.

这篇关于如何从 Sublime Text 3 Python 构建错误中删除 Windows PATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 10:48