[PYTHON] Programming environment for beginners made on Windows

Create a programming environment on Windows in 1 hour

Target audience

Beginners who want to create a programming environment on windows

Target
  1. Do hello world in C and Python within an hour
  2. Do not pollute the Windows environment as much as possible
  3. Allows you to continue using or reset the environment even if you step up

1. Enable WSL

First, enable WSL (Windows Subsystem for Linux). This is a service that runs an OS called Linux on Windows. Originally, it is difficult to build a programming environment in Windows compared to other OS such as MacOS and Linux, so I only have a Windows PC, but I want to program! For the time being, let's try it with the C language I learned at university! It was a level to fold at the stage of environment construction. On the other hand, Linux is an OS that makes it very easy to build a programming environment, but the task of putting Linux on a Windows PC is quite troublesome. Fortunately, Microsoft has a service called WSL, so let's use it. This service is unthinkable a long time ago.

1.1 Open Control Panel

The Control Panel can be opened by right-clicking the Windows icon at the bottom left and typing Control Panel in "Search" that appears.

1.2 Enable WSL

Select "Programs and Features" from the menu in the control panel. Click Enable or Disable Windows Features on the right menu.

1.3 Enabling WSL

Find the Windows Subsystem for Linux in the window that opens and check it. Let's reboot once to enable WSL. 1.png

2. Get Ubuntu, Windows Terminal, VS Code for WSL

Get an app called Ubuntu from the Microsoft Store. This is an image of the OS running on WSL. There are Ubuntu, Ubutnu18.04, Ubuntu16.04, but let's choose Ubuntu18.04 here. There is not much difference. Please start after downloading. A black screen will be displayed and you will be asked to set a user name and password in English. Enter it. キャプチャ.PNG Also, get Windows Terminal. It is a preview version, but there is no particular problem. キャプチャ2.PNG Also, download and install an editor called VS Code. https://code.visualstudio.com/

When Windows Terminal starts, open the settings in the menu bar.

2020-02-17.png If you open Setting here, VS Code should start up. キャプチャ.PNG On the upper side of the screen

setting.json


"defaultProfile": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}"

Set the value of "defaultProfile" (c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40) A guid of settings for Ubuntu that appears when you scroll down (c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40)

setting.json


            {
                "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
                "hidden": false,
                "name": "Ubuntu-18.04",
                "source": "Windows.Terminal.Wsl"
            }

Replace with and save by overwriting. Now, when you open Windows terminal, the Ubuntu terminal will open automatically.

3. Ubuntu update, installation of necessary tools

Open an Ubuntu terminal and copy and paste the following command. You can paste to the terminal with shift + crtl + V. You will be asked for a password, so enter the password you entered when setting up Ubuntu for the first time.

ubuntu.update


sudo apt update
sudo apt upgrade
sudo apt install build-essential          

It will take some time, but think of it as an Ubuntu update and wait.

4. Install the extensions required for VS Code

Open VSCode and click File> Setting> Extension on the menu bar to open a menu where you can install the extension. Therefore, please install the following extensions. Japanese Language Pack for VS Code Remote - WSL

Open the Ubuntu terminal again and

openvscode


code .         

Enter. Now you can run VS Code on Ubuntu. Also, extensions from VS Code opened in the terminal Python C/C++ Please put in. These extensions point out mistakes in the supported programming languages and add highlights that make your code easier to read. This completes the minimum environment construction.

5. Creating a program

5.1 C language

Create a C language hello world file with VS Code and save it. This time, let's assume that you saved it to Desktop.

hello_world.c


#include <stdio.h>

int main(){
    printf("Hello World!\n");
    return 0;
}      

Click Terminal> New Terminal in the VS Code menu and you should see a terminal screen at the bottom. To that terminal

move_dir


cd Desktop
gcc hello_world.c
./a.out

If you type, the terminal will move to the Desktop folder, compile the hello_world.c file, execute the output a.out file, and output Hello World! To the terminal. Congratulations! You now have a C language development environment. Create more and more programs, compile and run them.

5.2 Python For Python it's easier.

hello_world.py


print("Hello World!")

And also from the terminal

move_dir


cd Desktop
python hello_world.py

Just do. Congratulations! You now have a Python development environment! It's easy! If you want to write in Python, go to the terminal.

installmojule


sudo apt install python3-pip
pip3 install jupyter
pip3 install ipython
pip3 install numpy scipy matplotlib pandas scikit-learn flask

You can install the required modules at.

6. Try another language

Of course, you can easily create not only C and Python but also other programming languages. From google search

Ubuntu (the programming language you want to use)

All you have to do is enter the command in the article found in the search in, and put the extension of that programming language in VS Code. Golang: https://github.com/golang/go/wiki/Ubuntu Rust : https://www.rust-lang.org/tools/install

Let's enjoy programming!

Recommended Posts

Programming environment for beginners made on Windows
Building an environment for "Tello_Video" on Windows
Installing TensorFlow on Windows Easy for Python beginners
Prepare Chainer environment on Windows
F2py on Miniconda for Windows
Build Python environment on Windows
Python3 environment construction (for beginners)
Django environment development on Windows 10
Procedure for building a CDK environment on Windows (Python)
Build python environment on windows
[Tensorflow] Tensorflow environment construction on Windows 10
Building a Python environment for programming beginners (Mac OS)
Cross development environment (developing programs for windows on linux)
Linux beginners create Ubuntu 16.04 environment on Docker (for Mac)-first half-
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Install python2.7 on windows 32bit environment
[For beginners] Django -Development environment construction-
Create a Linux environment on Windows 10
Install Python development environment on Windows 10
pykintone on Windows Subsystem for Linux
Create a Python environment for professionals in VS Code on Windows
Notes for using OpenCV on Windows10 Python 3.8.3.
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Python project environment construction procedure (for windows)
"Python AI programming" starting from 0 for windows
[Note] Procedures for installing Ubuntu on Windows 10
Creating a python virtual environment on Windows
I built a TensorFlow environment on windows10
Building an environment for "Tello_Video" on Raspbian
A textbook for beginners made by Python beginners
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
Rock-paper-scissors with Python Let's run on a Windows local server for beginners
For beginners to build an Anaconda environment. (Memo)
A tool for creating symbolic links on Windows
Prepare a programming language environment for data analysis
Roadmap for beginners
Python on Windows
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Simply build a Python 3 execution environment on Windows
python windows environment
Run yolov4 "for the time being" on windows
Image Processing with Python Environment Setup for Windows
Building an environment for matplotlib + cartopy on Mac
Build a Kubernetes environment for development on Ubuntu
Notes for using TensorFlow on Bash on Ubuntu on Windows
Introduction to Programming (Python) TA Tendency for beginners
[For beginners] How to study programming Private memo
Create a Python virtual development environment on Windows
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build a local development environment for Laravel6.X on Mac
Building an environment for "Tello_Video" on Mac OS X
Build a Python extension for E-Cell 4 on Windows 7 (64bit)
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Create a comfortable Python 3 (Anaconda) development environment on windows
[For beginners] Install the package in the Anaconda environment (Janome)
A memo of installing Chainer 1.5 for GPU on Windows
Building a TensorFlow environment that uses GPU on Windows 10
I made a Python3 environment on Ubuntu with direnv.
Build a GVim-based Python development environment on Windows 10 (1) Installation