LoginSignup
93
141

More than 1 year has passed since last update.

Visual Studio CodeでPython開発環境を整える

Last updated at Posted at 2017-03-17

0. はじめに

以前、Visual Studio Codeを使ってHTML作成環境を整えるというQiitaを書きましたが、昨今、機械学習(深層学習を含む)が流行っており、Pythonをベースにした書籍が多く出版されています(Amazon:Python機械学習プログラミングAmazon:ゼロから作るDeep Learning ―Pythonで学ぶディープラーニングの理論と実装、など)。そこで今回はVisual Studio CodeでPython開発環境を準備してみることにしました。

対象のVisual Studio Codeのバージョンは 1.63.2 です。Pythonのバージョンは 3.10.1 です。

1. Windows環境にPythonをインストール

パッケージマネージャーのchocolateyを利用します。
chocolateyをインストールしていない場合は、下記のコマンドでインストールを実行。

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

インストールはすぐに終わります。コマンドプロンプトを立ち上げなおして、chocoコマンドでpythonを導入。

choco install python

1-2. VSCodeにPython拡張をインストール

下記のPython拡張用のアドインはコーディングに必要な一通りの機能(デバッグ、インテリセンス、等)が揃っています。

プラグイン 名前とリンク 用途
image Python Linting, Debugging (multi-threaded, remote), Intellisense, code formatting, refactoring, unit tests, snippets, and more.

Visual Studio CodeでCtrl+Pでコマンドパレットを開き、下記のコマンドを実行。

ext install Python

拡張機能ペインから「Python」を選択し、「インストール」をクリック。

1-3. リンターをインストール

ソースコードの自動フォーマットのためにリンターをインストールします。最近のおすすめはblack。別のQiitaにまとめましたので、そちらを参照してください。

2. おわりに

これでセットアップ完了です。特に引っかかることもなかったです。

参考

93
141
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
93
141