LoginSignup
4
5

More than 3 years have passed since last update.

VSCode にPython仮想環境を追加する

Last updated at Posted at 2020-06-06

はじめに

venvで作成した仮想環境が,Visual Studio Codeの"select interpreter"で表示されずつまづいたのでメモしておきます。

前提

  • macOS Catalina 10.15.5
  • Visual Studio Code 1.45.1
  • Python 3.8.2

Pythonの仮想環境作成

Pythonの仮想環境作成にはvenvを使用しました。最新のPythonであれば標準で実装されています。詳しくはこちら

仮想環境を作ります。将来的に複数の仮想環境を用意することを想定して,"python_envs"というフォルダを用意して仮想環境をまとめました。機械学習と画像処理用の環境なので,名前は"mlcv"です。

python3 -m venv python_envs/mlcv

VSCodeの仮想環境読み込み先を設定

"python_envs"に作った仮想環境をVSCodeが自動で読み込むよう設定します。
command + , で設定画面を開き,"venv folders"と検索します。

Screen Shot 2020-06-06 at 17.02.33.png

"Add Item"をクリックし,"python_envs"のパスを入力して完了。

Screen Shot 2020-06-06 at 17.05.02.png

shift + command + pでコマンドパレットを開き,"select interpreter"を実行するとPython環境の一覧が表示されます。一番下に先程作成した仮想環境"mlcv"が追加されました。

4
5
1

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
4
5