はじめに
- 先日、MacにAnacondaでPython開発環境を構築しました。Jupyter Notebookでお勉強をしているのですが、ブレークポイントを貼ってデバックしたい自分にとって辛いときがあるので、開発環境を整えることにしました。そこで、開発エディタとしてVisual Studio Code(VSCode)を使用してみようと思い、その時のインストール、設定方法を自分用の備忘録としてまとめました。
動作環境
- macOS Mojave 10.14.6
- Homebrew 2.1.10
- conda 4.5.11
- python 3.6.8
#1. Visual Studio Codeのインストール
- HomeBrewを使用しているので、
brew
でインストールします。
方法
- パッケージの検索。
- インストール。
bash
# パッケージの検索
$ brew search visual
# ログ
==> Casks
homebrew/cask-versions/visual-studio-code-insiders
︙
homebrew/cask/visual-studio-code
# インストール
$ brew cask install visual-studio-code
# ログ
Updating Homebrew...
==> Auto-updated Homebrew!
︙
==> Updated Formulae
︙
==> Tapping homebrew/cask
︙
==> Satisfying dependencies
==> Downloading https://az764295.vo.msecnd.net/stable/036a6b1d3ac84e5ca96a17a44e
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'visual-studio-code'.
==> Installing Cask visual-studio-code
==> Moving App 'Visual Studio Code.app' to '/Applications/Visual Studio Code.app
==> Linking Binary 'code' to '/usr/local/bin/code'.
🍺 visual-studio-code was successfully installed!
#2. Visual Studio Codeの設定
日本語化
- インストール後、VSCodeを起動すると英語表示だったので、日本語表記に変更しました。
方法
Python拡張機能のインストール
方法
- VSCodeの
EXTENSIONS
から、__「Python」__をインストール。

Python実行環境の設定
- デフォルトのPython実行環境を指定したい場合は「ユーザ設定(settings.json)」に設定します。
- ワークスペース毎にPython実行環境を指定したい場合は「ワークススペース設定(settings)」に設定します。
方法
-
Command
+Shift
+P
でコマンドパレットを開く。 - 入力コンソールで__「Python:Select Interpreter」__を検索し、選択する。


- 「ユーザ設定」の場合、上記の設定値は「~/.Library/Application Support/Code/User/settings.json」内の「python.pythonPath」に設定される。

