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
Python Development Environment Configuration
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.
- Python
- IDEs and text editors
- OS
Introduce Python
The following process will take 5 minutes to install Python.
- Download Python Installer
- Install Python
- 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
Installation of VSCode takes only 5 minutes
- Download VSCode Installer
- Install VSCode
- Confirm VSCode startup
Download VSCode Installer
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.
② 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
The process of making Python available in Visual Studio Code takes only 15 minutes!
- Add Extension for Python
- Set Path for Python
- Verify Python and library operation
- 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.
- Open the file location from the Windows button on the taskbar
- 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
- Create a new folder
- Open the folder in VSCode
- Create a python file test.py in the folder
- Write code and execute it by pressing F5→Confirm Python operation
- 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
- Open the folder in VSCode
- Create a python file test.py in the folder
- 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.
- 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
Comments