Transferred from: Edwardgui's Blog
The normal use of Python to compile the console is not garbled, but in the case of using a virtual environment, Chinese is always garbled, the first thought is the Windows console encoding problem. Looking for a long time after the discovery is python+virtualenv compiler system problems, and now I will lead you to solve this problem.
▲ Note: Under Windows environment
- First look at whether the Virtualenv package plugin has been installed, if not, then Ctrl+shift+p,install package, enter VIRTUALENV installation.
- Find the plug-in installation: C:\users{username}\appdata\roaming\sublime Text 3\installed Packages ==> pay attention to change Username
- Unzip the Virtualenv.sublime-package file by first adding the suffix. zip to Virtualenv.sublime-package.zip and unzip
The Include files are as follows:
To modify the Python + virtualenv.sublime-build file, add a line:"env": {"PYTHONIOENCODING": "utf8"},
Make it into
{"env": {"PYTHONIOENCODING": "utf8"},"target": "virtualenv_exec","shell_cmd": "python -u \"$file\"","file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)","selector": "source.python"}
Then save, then package the file as Virtualenv.sublime-package.zip and remove the suffix, and you're done.
Finally open sublime Text3 use Python + virtualenv compile, you can see the normal output of Chinese!
Sublime Text3 python Virtual Environment (supplemental)--Fix the console in Chinese garbled condition