Sublime text 2 supports compiling Python 2.75

Time:2021-8-18

1. Configure compilation path

Click "preference" -- \ > "browse packages" -- \ > "Python", edit the python.sublime-build file, and add the path of the python application. My installation is in the path of C: \ Python 27:
{
  "cmd":["python.exe", "-u", "$file"],
  "path":"C:/Python27", 
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.python"
  }
The code path and environment variable path do not contain Chinese, and the Chinese support is not good. After writing the program, you need to save it before it can run. Press Ctrl + B when running.

2. Process the default code of sublime

During the configuration process, I encountered the following error reporting problem:

> Traceback (most recent call last):                                      
File ".\sublime_plugin.py", line 325, in run                          
File ".\exec.py", line 145, in run                                    
File".\exec.py", line 42, in __init__                                
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position
9: ordinal not in range(128)

The cause of this problem is that exec.py in the packages \ default directory of the configuration file directory is editing the environment variable, but the ASCII character set is missing in the character set of the environment variable.



Solution: browse packages under preferences, open packages \ default \ exec.py, and find 43~44 edit

     for k, v in proc_env.iteritems():                                                                         proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())

 a. Delete it decisively!
 b. Exception handling is carried out on it to avoid stopping the program when it makes an error, like this:
      for k, v in proc_env.iteritems():
         try:
           proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())
         except UnicodeDecodeError:
           print "Encoding error..."
           print "VARIABLE: ", k, " : ", v

Then you’ll find that you’d better be honest and practical pycharm.