0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python windows 環境構築

0
Last updated at Posted at 2021-01-02

◆windows環境でのVSCodeを使用したpython開発環境構築

・構築環境
  windows10
  python
  VSCode
  tortoiseGit

・参考サイト
 Python環境構築ガイド
 https://www.python.jp/install/windows/install.html


◆python本体
  1.ダウンロード
   https://www.python.org/downloads/
   インストール時に "Add Python 3.x to PATH" をチェックする

  2.インストール後に本体確認 
   C:\Users\testuser1>python
   quit()

  3.pythonランチャー確認
   C:\Users\testuser1>py
   quit()


◆VScode
  1.ダウンロードとインストール
  https://code.visualstudio.com/download

  2.エディタを立ち上げて拡張機能追加
  ・Japanese Language Pack for Visual Studio Code
  ・Git Graph


◆pythonサンプルコードを作成
 sample.py (pipでパッケージをインストールをしていなければ実行時にエラーがでる)

   import requests
   print(requests.get("https://www.python.jp").text)


◆仮想環境
 参考 https://www.python.jp/install/windows/venv.html

  1.プロジェクトフォルダの作成 
    C:\Users\user1>mkdir sample1

  2.仮想環境フォルダ作成
    C:\Users\user1\sample1>python -m venv .venv

--コマンドプロンプトの場合
  3.仮想環境activate(cmd)
    C:\Users\user1\sapmle1>.venv\Scripts\activate.bat
    (.venv) C:\Users\user1\sample1>

  4.pipで仮想環境にパッケージをインストール
    (.venv) C:\Users\user1\sample1>python -m pip install requests

  5.仮想環境deactivate
    (.venv) C:\Users\user1\sample1> deactivate
    C:\Users\user1\sample1>

--powershellの場合
  ・powershellの実行権限付与
    PS C:> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

  ・仮想環境activate(ps)
    PS C:\Users\user1\sapmle1> .venv\Scripts\activate.ps1
    (.venv) C:\Users\user1\sample1>


◆Cコンパイラインストール

  1.「Visual Studio 2019のツール」を選択(downloadsページの下の方にある)
    https://visualstudio.microsoft.com/ja/downloads/

  2.「Build Tools for Visual Studio 2019」をダウンロード

  3.インストーラを起動し、「C++ Build Tools」 を選択して インストール


◆仮想環境運用方法
  1.使用している仮想環境のパッケージをrequirements.txtに出力
    (.venv) C:\Users\user1\sample1>python -m pip freeze > requirements.txt

  2.requirements.txtを参照して仮想環境にパッケージをインストール
    (.venv) C:\Users\user1\sample1>python -m pip install -r requirements.txt


◆pythonのバージョンごとに仮想環境をわける

  ・3.7系
    C:\Users\user1>py -3.7 -m venv py37env
    C:\Users\user1>py37env\Scripts\activate.bat

  ・3.8系
    C:\Users\user1>py -3.8 -m venv py38env
    C:\Users\user1>py38env\Scripts\activate.bat


◆バージョン管理ツール
  ・git
    https://git-scm.com/download/win

  ・tortiseGit & Language Packs
    https://tortoisegit.org/download/

  ・tortiseGit参考動画
    https://youtu.be/5NEuiuqElio

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?