◆ Building a python development environment using VS Code in a windows environment
・ Construction environment windows10 python VSCode tortoiseGit
・ Reference site Python Environment Construction Guide https://www.python.jp/install/windows/install.html
◆ python body
Download https://www.python.org/downloads/ Check "Add Python 3.x to PATH" during installation
Check the main unit after installation C:\Users\testuser1>python quit()
Python launcher confirmation C:\Users\testuser1>py quit()
◆VScode
Download and install https://code.visualstudio.com/download
Launch the editor and add extensions ・ Japanese Language Pack for Visual Studio Code ・ Git Graph
◆ Create python sample code sample.py (If you don't install the package with pip, you will get an error at runtime)
import requests print(requests.get("https://www.python.jp").text)
◆ Virtual environment Reference https://www.python.jp/install/windows/venv.html
Create a project folder C:\Users\user1>mkdir sample1
Create virtual environment folder C:\Users\user1\sample1>python -m venv .venv
--For command prompt 3. Virtual environment activate (cmd) C:\Users\user1\sapmle1>.venv\Scripts\activate.bat (.venv) C:\Users\user1\sample1>
Install the package in the virtual environment with pip (.venv) C:\Users\user1\sample1>python -m pip install requests
Virtual environment deactivate (.venv) C:\Users\user1\sample1> deactivate C:\Users\user1\sample1>
--for powershell ・ Grant execution authority of powershell PS C:> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
・ Virtual environment activate (ps) PS C:\Users\user1\sapmle1> .venv\Scripts\activate.ps1 (.venv) C:\Users\user1\sample1>
◆ C compiler installation
Select "Visual Studio 2019 Tools" (at the bottom of the downloads page) https://visualstudio.microsoft.com/ja/downloads/
Download "Build Tools for Visual Studio 2019"
Launch the installer and select "C ++ Build Tools" to install
◆ Virtual environment operation method
Output the package of your virtual environment to requirements.txt (.venv) C:\Users\user1\sample1>python -m pip freeze > requirements.txt
Refer to requirements.txt to install the package in the virtual environment (.venv) C:\Users\user1\sample1>python -m pip install -r requirements.txt
◆ Separate virtual environments for each python version
・ 3.7 series C:\Users\user1>py -3.7 -m venv py37env C:\Users\user1>py37env\Scripts\activate.bat
・ 3.8 series C:\Users\user1>py -3.8 -m venv py38env C:\Users\user1>py38env\Scripts\activate.bat
◆ Version control tool ・ Git https://git-scm.com/download/win
・ TortoiseGit & Language Packs https://tortoisegit.org/download/
・ TortoiseGit reference video https://youtu.be/5NEuiuqElio
Recommended Posts