Python+VSCode+Windows 11 environment! A must for beginners!

Python is one of the most popular programming languages in the world!

It is very easy to use for AI, machine learning, and data analysis because of its extensive libraries, and it is also easy for beginners to understand.

However, the initial environment construction is also the most difficult point for beginners, and it is not at all clear which environment is the best.

In this article, I will explain the simplest and most suitable Python development environment for AI development, based on my own prejudice as a researcher who has been using Python for a long time.

Using Python 3.11, Visual Studio Code, and Windows 11 (64bit), I will show you how to build the simplest and most powerful Python environment in 20 minutes.

If you want to build an environment specialized for data analysis with Anaconda, please refer to the following article

Table of Contents

Python Development Environment Configuration

black laptop computer turned on on table

The best Python development environment is a combination of the text editor Visual Studio Code (VSCode)

VSCode includes all the functions for writing Python code, executing it, and fixing errors.

Compared to other text editors, the overwhelming advantage of VSCode is that it is very lightweight and runs very smoothly.

Simple Python development environment
Python

Python 3.12.4

IDEs and text editors

Visual Studio Code 1.75

OS

Windows 11 64bit

If you are using Windows, the procedure is basically the same as in this article

Introduce Python

https://www.python.org/community/logos/

The following process will take 5 minutes to install Python.

Python Introduction Process
  1. Download Python Installer
  2. Install Python
  3. Verify Python operation with command prompt

① Download Python Installer

Download from the official Python website

Please click the link below to access the official website and download the latest version of Python.

② Install Python

Double-click the downloaded installer or right-click and run to install.

Then proceed as shown in the image below.

③ Verify Python operation with command prompt

After the Python installation is complete, check to see if Python has been successfully installed from the command prompt

Click the Windows symbol on the taskbar to launch the command prompt

python -V

If the version information returns Python 3.11.2, the installation is successful.

Install Visual Studio Code

https://code.visualstudio.com/

Installation of VSCode takes only 5 minutes

VSCode Introduction Process
  1. Download VSCode Installer
  2. Install VSCode
  3. Confirm VSCode startup

Download VSCode Installer

https://code.visualstudio.com/

Download from the official VSCode website

Click on the link below to access the official website and download the latest version of VSCode!

If you are not using 64-bit Windows, please go to the bottom of the official site top page and select the installer.

https://code.visualstudio.com/

② Install VSCode

Double-click the downloaded installer or right-click and run to install.

Then proceed as shown in the image below.

③ Restart PC

Restart your PC after the VSCode installation is complete.

Use Python with Visual Studio Code

https://www.python.org/community/logos/
https://code.visualstudio.com/

The process of making Python available in Visual Studio Code takes only 15 minutes!

Python+VSCode implementation process
  1. Add Extension for Python
  2. Set Path for Python
  3. Verify Python and library operation
  4. Install libraries with pip and see how they work

Now, let’s start VSCode and go through the steps in order.

Press the Windows button on the taskbar and type “Visual Studio Code

① Add Extension for Python

VSCode can be enhanced and made more useful by installing extension packs

Python extension for Visual Studio Code is a Python-specific extension pack.

② Set Python Path

Search for “Python: Default Interpreter Path” and enter the path to python.exe

The location of python.exe and how to get the path are described below the image.

If you do not see “Python: Default Interpreter Path”, restart VSCode.

How to find the path to python.exe
  1. Open the file location from the Windows button on the taskbar
  1. Right-click on python.exe and copy the path (delete the “” in the path later)

③ Verify Python and library operation

Create a Python file and try to see if you can actually program in VSCode

Operation Verification Process
  1. Create a new folder
  2. Open the folder in VSCode
  3. Create a python file test.py in the folder
  4. Write code and execute it by pressing F5→Confirm Python operation
  5. Execute the code including import by pressing F5→Confirm the library operation
  • Create a new folder

Create a folder anywhere you like to store your Python files

  1. Open the folder in VSCode
  1. Create a python file test.py in the folder
  1. Confirm Python operation

Write code in test.py

print('Completed')

Execute the above code in Python by pressing F5 on the keyboard or the triangle in the upper right corner.

You should see a text output in the Terminal at the bottom of VSCode saying that the configuration is complete.

  1. Confirm the library operation

Add import datetime to test.py and write the code

import datetime

print(datetime.datetime.today())

# 2024-08-02 06:25:44.650167

Execute the above code by pressing F5 on the keyboard

The Terminal at the bottom of the VSCode should output today’s date and time.

④ Install library by pip and check its operation

Finally, add the library and see if it runs

Install Numpy, a library for numerical calculations that is always used for calculations in AI

pip install numpy

///
Collecting numpy
  Downloading numpy-1.24.2-cp311-cp311-win_amd64.whl (14.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.8/14.8 MB 930.8 kB/s eta 0:00:00Installing collected packages: numpy
Successfully installed numpy-1.24.2
///

After successful installation, write and run the code in numpy

import numpy

# Create a numerical list
x = [1, 31, 56 , 74]
# Total value calculation with sum
print(numpy.sum(x))

# 162

Once you have completed this step, all that remains is to develop the product as you see fit!

References

Python

Visual Studio Code

numpy

I hope you will share it with me!
  • URLをコピーしました!

Comments

コメントする

Table of Contents