LoginSignup
0
1

More than 3 years have passed since last update.

VScode 上でEC2のファイル操作・conda enviromentを使用する方法

Last updated at Posted at 2019-10-16

目的

VScode で EC2へssh接続し、
VScode上でEC2 Deep Learning AMIに入っているCondaを利用してpython Scriptを
動かすまでの手順を記載します。

背景

普段はEC2上でjupyter serverを立ち上げてデータ分析を行っているのですが、
VScodeの強力な拡張機能を使ってみたくてやってみました。

前提

Windows環境で実施しました。
Vscodeをinstall済み
EC2を立ち上げ済み
Gitをインストール済み

VScode上の設定

MARKET PLACEからRemote Developmentをインストール
image.png

左にRemote Developmentのアイコンが表示されるので、そこを押してから
image.png

sshを設定する
image.png

Host EC2
    HostName xxx.xxx.xxx.xxx #EC2のIP
    User ubuntu
    IdentityFile #.pemファイルのディレクトリ
    CheckHostIP no
    ControlMaster auto
    ControlPersist  600
    IdentitiesOnly yes
    ForwardAgent yes
    RemoteForward 22 127.0.0.1:22

VScode上の歯車マーク→設定 から検索バーにremote sshを入れて、設定を行います。

設定箇所は
Config File #sshのconfig設定場所を設定
Path #使用するsshの場所を設定
   自分はGitのsshでないとpermision deniedが出て、使えませんでした。
Show Login Terminal #有効にする。

次にEC2をクリックしてEC2へ接続する
image.png

接続したらEC2にもpython extensionを追加する。
image.png

最後にpython enviromentを使用したいものを選択
image.png

以上です!あとはEC2上でpythonファイルを作ってコードがりがり書いていきましょう。

0
1
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
0
1