How to remove the Windows PATH from a Sublime Text 3 Python build error?

允我心安 提交于 2019-12-03 03:21:46

问题


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.

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.


回答1:


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.

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

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"]) + "]"

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

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.

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.



来源:https://stackoverflow.com/questions/36611270/how-to-remove-the-windows-path-from-a-sublime-text-3-python-build-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!