Windows 10 pro + VsCode + Python3 を使ってみる

Windows 10 pro + VsCode + Python3 を使ってみる

python-3.6.4-amd64.exeを実行して /path/to/python\python36
とインストールしている

python3 のみをインストールしている場合 pylint を要求してくるので
以下の手順で追加する

拡張機能として Python-vscode をインストールしてみる
※pylint、Flake8が require されているのもある
 
> chcp 65001
Active code page: 65001
 
PowerShellコンソールのコードページが s-jis の場合はエラーになる為
utf-8 に変更してpip3より追加する
 
> pip3 install pylint
Collecting pylint
Using cached pylint-1.8.2-py2.py3-none-any.whl
Requirement already satisfied: isort>=4.2.5 in /path/to/python\python36\lib\site-packages (from pylint)
Collecting astroid<2.0,>=1.6 (from pylint)
Using cached astroid-1.6.1-py2.py3-none-any.whl
Requirement already satisfied: mccabe in /path/to/python\python36\lib\site-packages (from pylint)
Requirement already satisfied: colorama; sys_platform == "win32" in /path/to/python\python36\lib\site-packages (from pylint)
Requirement already satisfied: six in /path/to/python\python36\lib\site-packages (from pylint)
Collecting wrapt (from astroid<2.0,>=1.6->pylint)
Using cached wrapt-1.10.11.tar.gz
Requirement already satisfied: lazy-object-proxy in /path/to/python\python36\lib\site-packages (from astroid<2.0,>=1.6->pylint)
Installing collected packages: wrapt, astroid, pylint
Running setup.py install for wrapt ... done
Successfully installed astroid-1.6.1 pylint-1.8.2 wrapt-1.10.11
 
> pip3 install Flake8
Collecting Flake8
Downloading flake8-3.5.0-py2.py3-none-any.whl (69kB)
100% |████████████████████████████████| 71kB 199kB/s
Collecting pycodestyle<2.4.0,>=2.0.0 (from Flake8)
Downloading pycodestyle-2.3.1-py2.py3-none-any.whl (45kB)
100% |████████████████████████████████| 51kB 410kB/s
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in /path/to/python\python36\lib\site-packages (from Flake8)
Collecting pyflakes<1.7.0,>=1.5.0 (from Flake8)
Downloading pyflakes-1.6.0-py2.py3-none-any.whl (227kB)
100% |████████████████████████████████| 235kB 468kB/s
Installing collected packages: pycodestyle, pyflakes, Flake8
Successfully installed Flake8-3.5.0 pycodestyle-2.3.1 pyflakes-1.6.0
 
>chcp cp932 # はエラーになるのな・・・・
 
vscode拡張機能より
Python-vscode をインストールする
 
プラグインは 以下(現時点でのメモ)
beautify
code runner
Debugger for Chrome
Debugger for PhantomJS
evilinspector
JavaScript (ES6) snippets
mssql
Visual Studio Team Services
Node.js Modules Intellisense
Open in Browser
Python
Python-vscode
Scanner.js
VS Code database
 
以下設定メモ
ファイル→基本設定→設定 を選択すると「settings.json」ファイルが開くため、下記のとおり設定。
settings.json
{
// エディターでインデントのガイドを表示する必要があるかどうかを制御します
"editor.renderIndentGuides": true
}
 
VsCode 1.22.2 で確認
環境変数に PYTHONIOENCODING:UTF-8 を設定するとUTF-8で出力パネルに表示されます

ファイルを作成して run code で実行すると、vscodeの出力で日本語が文字化けしてしまう
デフォではいつ直るのか不明なので、以下を参考に
[Visual Studio Code][Python][Windows] VSCodeのタスク/デバッグ出力でのPythonの日本語文字化け対応
とりあえずこちらで対応
Windows 10 Pro + VsCode + Python3 で出力先をターミナルに変更してみる


# -*- coding: utf-8 -*-
#---追加
import sys
import io

sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
#---追加

print('日本語')

これはこれで めんどくさいなぁ・・・