Create a python3 build environment with Sublime Text3

When I tried to create a build environment for python3 with SublimeText3, I couldn't display Japanese with UnicodeEncodeError, so this is the solution.

environment

error

If you build the following script of python3 in the default state, you will get UnicodeEncodeError.

tmp.py


# -*- coding: utf-8 -*-

import platform

print(platform.python_version())
print('Japanese')

error

3.4.2
Traceback (most recent call last):
  File "/Users/XXXXXXX/Desktop/tmp/tmp.py", line 6, in <module>
    print('\u65e5\u672c\u8a9e')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
[Finished in 0.3s with exit code 1]
[shell_cmd: python -u "/Users/XXXXXXX/Desktop/tmp/tmp.py"]
[dir: /Users/XXXXXXX/Desktop/tmp]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

Solution

From Tools => Build System => New Build System ..., enter the following and save as Python3.sublime-build

Since I use pyenv to switch the version, the path is /Users/XXXXXXX/.pyenv/shims/python3, but if it is not installed, check the path with which python3 from the terminal and rewrite it yourself.

Python3.sublime-build


{
	"cmd": ["/Users/XXXXXXX/.pyenv/shims/python", "-u", "$file"],
	"selector": "source.python",
	"file_regex": "file \"(...*?)\", line ([0-9]+)",
	"env": {"LANG": "ja_JP.UTF-8"}
}

Recommended Posts

Create a python3 build environment with Sublime Text3
Create a virtual environment with Python!
Set up a Python development environment with Sublime Text 2
Create a Python environment
Build a python virtual environment with pyenv
Build a modern Python environment with Neovim
Build a python environment with ansible on centos6
Create a virtual environment with conda in Python
[Python] Build a Django development environment with Docker
Build a Python environment with OSX El capitan
Quickly build a Python Django environment with IntelliJ
Build a Python machine learning environment with a container
Build a python execution environment with VS Code
Build python3 environment with ubuntu 16.04
Build python environment with direnv
Build a Python environment offline
Create a directory with python
Build a python virtual environment with virtualenv and virtualenvwrapper
Create a python development environment with vagrant + ansible + fabric
Build a machine learning application development environment with Python
Build a python virtual environment with virtualenv and virtualenvwrapper
GOTO in Python with Sublime Text 3
Build python virtual environment with virtualenv
Create a Python environment on Mac (2017/4)
Build Mysql + Python environment with docker
Enable Python raw_input with Sublime Text 3
Building a virtual environment with Python 3
Create a python environment on centos
Build a python3 environment on CentOS7
How to build a python2.7 series development environment with Vagrant
Create a simple Python development environment with VSCode & Docker Desktop
Build a python environment with pyenv (OS X El Capitan 10.11.3)
Create a Todo app with Django ① Build an environment with Docker
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
[Pyenv] Building a python environment with ubuntu 16.04
Building a Python3 environment with Amazon Linux2
Easily build a development environment with Laragon
Build Jupyter Lab (Python) environment with Docker
Create a dummy image with Python + PIL.
Build a python environment on MacOS (Catallina)
Build a Tensorflow environment with Raspberry Pi [2020]
Create a python environment on your Mac
Let's create a virtual environment for Python
Building a Python 3.6 environment with Windows + PowerShell
I want to build a Python environment
Build a Fast API environment with docker-compose
Create Python + uWSGI + Nginx environment with Docker
Create a large text file with shellscript
Create a virtual environment with Python_Mac version
Build Python environment with Anaconda on Mac
Create a word frequency counter with Python 3.4
[Linux] Build a jenkins environment with Docker
Build a Python + OpenCV environment on Cloud9
Create a matrix with PythonGUI (text box)
Build AI / machine learning environment with Python
[Linux] Build a Docker environment with Amazon Linux 2
Create a Python execution environment for Windows with VScode + Remote WSL
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a Python environment on your Mac with Anaconda and PyCharm
Try to create a python environment with Visual Studio Code & WSL
Build a Python execution environment using GPU with GCP Compute engine