Data analysis in Python offers various advantages, such as an overwhelming increase in speed, a variety of data analysis methods, and the collection of a huge amount of data.
However, building an environment is the most difficult part for beginners, and it is hard to know which environment to choose.
In this article, I, as a researcher, will explain how to build a development environment for Python, which is the best tool for data analysis.
Using Anaconda, Visual Studio Code, and Windows 11, you will build the most suitable python environment for data analysis in 15 minutes.
Installation of Python development environment for data analysis
Anaconda+Visual Studio Code (VSCode) is the most recommended Python development environment for data analysis!
VSCode includes all functions for writing Python code, executing it, and fixing errors.
It is very lightweight and crisp compared to other text editors, which is an overwhelming advantage.
- Python
-
Anaconda (Python 3.9.12)
- IDE, text editor
- OS
Install Anaconda
Anconda can be installed in 5 minutes using the following procedure.
- Download Anaconda Installer
- Install Anaconda
① Download Anaconda Installer
Download from Anaconda Distribution
Click on the link below to access the official website and download the latest version of Anconda!
If you do not have Windows, please go to the bottom of the official site top page and select the installer.
② Install Anaconda
Run the installer by either double-clicking or right-clicking and selecting Run.
Then proceed as shown in the image below.
Install Visual Studio Code
VSCode can be installed in 5 minutes using the following procedure.
- Download VSCode Installer
- Install VSCode
- Restart PC
① Download VSCode Installer
Download from VSCode
Click on the link below to access the official website and download the latest version of VSCode!
If you do not have Windows, please go to the bottom of the official site top page and select the installer.
② Install VSCode
Run the installer by either double-clicking or right-clicking and selecting Run.
Then proceed as shown in the image below.
③ Restart PC
Restart your PC after the VSCode installation is complete.
Use Anaconda in VSCode
It takes 10 minutes to enable Anaconda in Visual Studio Code!
- Add extension for Python
- Set the Path of Anaconda’s python.exe
- Check Python and library operation
Now, let’s start VSCode and go through the steps in order
Press the Windows button on the taskbar and type “Visual Studio Code” to start it.
① Add extension for Python
VSCode comes with extension packs that add functionality and convenience.
Python extension for Visual Studio Code is an extension pack for Python.
② Set the path Anaconda’s python.exe
Click the Windows button on the taskbar to search for and launch Anaconda Prompt
In the Anaconda Prompt, type where python
and it will return the location (path) of python.exe
where python
# C:\Users\User\anaconda3\python.exe
Search for Python: Default Interpreter Path and enter the path to python.exe.
To check the location, open Explorer and look in C:\Users\user\anaconda3.
③ Check Python and library operation
Create a Python file and test if it actually works with VSCode.
- Create a new folder
- Open a folder in VSCode
- Create a python file test.py in the folder
- Write the code and press F5 to run it.→Check Python operation
- Execute code including import with F5→Check the library operation
④ Check Python operation
Write the code in test.py
print('Setup complete')
Write the above code and run Python by pressing F5 on the keyboard or clicking the triangle in the upper right corner.
In the Terminal at the bottom of the VSCode, you could see the text “Configuration Complete
print('Setup complete')
# Setup complete
If it is displayed, the path setting for Anaconda’s python.exe is complete.
⑤ Check the library operation
Add import numpy to the very first line and run
import numpy
# Create a list of numbers
x = [1, 31, 56 , 74]
# Total value calculation with sum
print(numpy.sum(x))
# 162
If there are no errors, the setup is complete here.
Q&A: How to solve a problem
This chapter explains how to solve common problems
If you too are having trouble setting up your environment, please ask questions in the comments section!
Anaconda Problems
I want to make sure Anaconda is installed.
①Windows Settings/application/Installed Apps, ②Control Panel/Programs/Programs and Functions, ③Click the Windows symbol on the taskbar / Add or Remove Programs, Start up with one of the aforementioned
The following image shows Anaconda’s presence.
I don’t know the location (path) of Anaconda’s python.exe as described in this chapter
Click the Windows button on the taskbar to search for and launch Anaconda Prompt
In the Anaconda Prompt, type where python
and it will return the location (path) of python.exe
where python
# C:\Users\User\anaconda3\python.exe
VSCode Problems
Python does not run in VSCode
Check that the path to python.exe in Python: Default Interpreter Path in this chapter is correct
(1) Is there double-cotation (“”)?
(2) Are the diagonal lines in the correct direction? (/ and \)
(3) Is the path the same as the path searched by Anaconda Prompt? (reference)
ImportError occurs in VSCode, and libraries such as numpy do not work
Make sure you have the path for the Anaconda libraries.
Click the Windows symbol on the taskbar, search for Edit Environment Variables, and check if the following path exists in Edit Environment Variables/User Environment Variables/Path, and if not, add it
C:\Users\User\anaconda3
C:\Users\User\anaconda3\Library\mingw-w64\bin
C:\Users\User\anaconda3\Library\usr\bin
C:\Users\User\anaconda3\Library\bin
C:\Users\User\anaconda3\Scripts
References
Anaconda
Visual Studio Code
numpy
Comments