From re-environment construction of Python to graph drawing (on visual studio code)

I want to study machine learning, Because I found a gap time and sporadically moved it by trial and error such as anaconda and vscode The execution environment has begun to get confused. .. .. Since we have rebuilt from zero base, we will summarize the procedure.

This article is composed of these two parts.

Specifically, we will do the following.

Step 1: Create an environment where python can run

Premise

What to do on Windows

Install python from the following https://www.python.org/downloads/windows/

Choose from Stable Releases This time, I chose "Windows x86-64 executable installer".

The exe file will be dropped, so install it quickly. image.png

What to do on vscode

Then, I would like to recreate the environment with vscode. An icon that looks like the "rice field" on the far left is broken (select the extension)

image.png

Then type "python" and install the python that probably hits the top

image.png

↓↓

image.png

At the same time, the dependent jupyter will also be installed

image.png

Then specify the Python path. Select Settings for Preferenes

image.png

And if you hit the following command

python.pythonpath

The screen for specifying the path will be displayed, so enter the correct path.

image.png

To find out the path in windows, I think you should open the executable file.

image.png

If you install it normally, you will lose such a path

user

C:\Users\*****\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.9

workspace

C:\Users\*****\AppData\Local\Programs\Python\Python39\python.exe

Then, create a hello.py file and execute it with the following contents.

msg = "hello world!"
print(msg)

Execution result ↓

hello world!

Congratulations! Now you have a minimum environment for python to work! !! !!

Step (2): Try drawing a graph

Build the environment

Because numpy and matplotlib are required Install using pip.

First of all, let's update pip.

py -m pip install -U pip

To install NumPy, execute the following command.

py -m pip install numpy

To install matplotlib, execute the following command.

py -m pip install matplotlib

The library environment for drawing graphs is now ready.

Actually draw a graph

Let's overwrite and execute hello.py as follows without detailed explanation.

import numpy as np
import matplotlib.pyplot as plt

msg = "Hello numpy and matplotlib"
print(msg)

x = np.linspace(0, 1, 5)
y = x ** 2
plt.plot(x, y)
plt.show()

If you can draw the graph below, you are successful!

image.png

The purpose of this article has been achieved, so it ends here! Thank you for your hard work!

bonus

For the purpose of using python If you want to do regression analysis etc., it is a good idea to include the pandas library at the same time.

py -m pip install pandas

With this, you can make up for missing data, sort data, etc. It is a library that is useful when preparing for analysis.

Recommended Posts

From re-environment construction of Python to graph drawing (on visual studio code)
Installation of Visual studio code and installation of python
From file to graph drawing in Python. Elementary elementary
App development to tweet in Python from Visual Studio 2017
Install python and Visual Studio Code on windows10 (April 2020 version)
Execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people) Environment construction
Update Python on Mac from 2 to 3
[Python] Try to graph from the image of Ring Fit [OCR]
Bash, Python, Javascript, code command, etc. in Visual Studio Code on Mac
Simple code to call a python program from Javascript on EC2
Run Python in C ++ on Visual Studio 2017
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Procedure from AWS CDK (Python) development to AWS resource construction * For beginners of development
Build an environment to execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people)
[Python] From morphological analysis of CSV data to CSV output and graph display [GiNZA]
Build Python development environment with Visual Studio Code
List of Python code to move and remember
Settings for Python coding in Visual Studio Code
I want to make C ++ code from Python code!
A note I was addicted to when running Python with Visual Studio Code
From Python environment construction to virtual environment construction with anaconda
[Visual Studio Code] [Python] Tasks.json + problemMatcher settings for Python
How to get started with Visual Studio Online ~ The end of the environment construction era ~
Execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people) Debugging
Try debugging Python on Raspberry Pi with Visual Studio.
Until drawing a 3D graph in Python on windows10
Preferences to generate animated GIFs from Python on Mac
[Updated from time to time] Review of Let Code NumPy
Get the return code of the Python script from bat
From python to running instance on google cloud platform
Make Visual Studio Code autocomplete for python external libraries
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment construction 2020 [From Python installation to poetry introduction]
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Procedure to exe python file from Ubunts environment construction
How to create a kubernetes pod from python code
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
How to build a Python virtual execution environment using Visual Studio Code and pipenv on a Windows machine (also Jupyter notebook)
Rewrite Python2 code to Python3 (2to3)
Graph drawing in python
Procedure from environment construction to operation test of testinfra, a server environment test tool made by Python
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
How to use linux commands in Visual Studio Code terminal
Set up a Python development environment with Visual Studio Code
How to debug the Python standard library in Visual Studio
Enable the virtualenv Python virtual environment for Visual Studio Code
I want to start a lot of processes from python
Memo of python + numpy/scipy/pandas/matplotlib/jupyterlab environment construction on M1 macOS (as of 2020/12/24)
Update monitoring of dmesg (/ dev / kmsg) from python on Linux
Do something like a Python interpreter in Visual Studio Code
Build Python3 for Windows 10 on ARM with Visual Studio 2019 (x86) on Windows 10 on ARM
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
VScode environment construction (on Mac) & graph display in Python (@browser)
Post from Python to Slack
Cheating from PHP to Python
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Handling of python on mac
Update python on Mac to 3.7-> 3.8
2.x, 3.x character code of python