1 of 16

ניתוח נתונים ולמידת מכונה

אמית רננים – חלופה ליחידה 3

מוטי בזר

mottibz@gmail.com

https://www.commridge.com

Installing Python and

Visual Studio Code

2 of 16

Installing Python and Visual Studio Code

What we will do:

  • Install Python on your system
  • Install Visual Studio Code (VSCode)
  • Enable Python integration within VSCode
  • Create a Virtual Environment
  • Install frequently used libraries
  • Installing and using Notebooks

2

Motti Bazar, mottibz@gmail.com

3 of 16

Installing Python [1]

  • Go to www.python.org
  • From the Downloads tab, select Windows (or macOS if you are using a Mac)

3

1

2

Motti Bazar, mottibz@gmail.com

4 of 16

Installing Python [2]

  • Scroll down and find Python 3.12.10 and click the 64-bit installer download
  • Launch the downloaded install
  • Make sure to click the “Add python.exe to PATH” [1]
  • Select Install Now [2]

4

1

2

Motti Bazar, mottibz@gmail.com

5 of 16

Test the Python installation

  • Start a command window (type “cmd” in the bottom-left search box)
  • At the command line, type “python” and verify that the Python interpreter is loaded and the version is 3.12.10 [1]
  • Type print(“hello”) and Enter and verify that it prints “hello” [2]
  • Type quit(), to quit the interpreter and go back to the command line [3]
  • If all works, Python is installed correctly

5

Motti Bazar, mottibz@gmail.com

1

2

3

6 of 16

Installing Visual Studio Code (VSCode) [1]

  • In the browser, search for “visual studio code download”
  • Click on this link:�or go directly to https://code.visualstudio.com/download
  • When the page loads, click on the�Windows installer icon

6

Motti Bazar, mottibz@gmail.com

7 of 16

Installing Visual Studio Code (VSCode) [2]

  • Launch the Visual Studio Code (VSCode) installer (the downloaded executable)
  • Click “I accept the agreement”
  • Click “Next”, and one more “Next”
  • In the displayed window, select the “Create a desktop icon” option and click “Next”
  • Click “Install”
  • Click “Finish” and VSCode will start

7

Motti Bazar, mottibz@gmail.com

8 of 16

Adding Python to Visual Studio Code

  • You will see a similar window to that:
  • Select the Extensions icon
  • A search box will open on the�upper-left corner
  • Type “python” in the search box
  • A list of optional extensions will open below the search box
  • From the list, install the Python extension by Microsoft by clicking on the extension and selecting Install

8

Motti Bazar, mottibz@gmail.com

9 of 16

Creating a Virtual Environment [1]

  • Every project may use a different set of libraries or different library versions
  • Once you setup and activate a virtual environment, the�packages/libraries you then install are isolated from other project environments, which avoid conflicts between projects
  • We will now create a Virtual Environment for our projects

9

10 of 16

Creating a Virtual Environment [2]

  • Create a folder under your C:\ drive, called Projects
  • In VSCode, click: File 🡪 Open Folder
  • Explorer window will open and you should select the C:\Projects folder that �you just created (your projects will be stored there)
  • Now go to the VSCode Command Pallet by clicking the following keyboard combination: �Control-shift-P (on Mac: Command-Shift-P)
  • In the opened window at the top, start typing �“Python: Create Environment…” (without the quotes)
  • As you type, you will see a menu below for �selecting the command
  • Select that command, and then select the “venv” option
  • You will see a list of Python interpreters to select from. �Select the one we just installed (3.12.10)
  • Progress will be presented on the lower-right corner of the VSCode �window and the Virtual Environment will be created

Note: The symbol 🡪 means an operation followed by another operation

10

Motti Bazar, mottibz@gmail.com

11 of 16

Verifying the Virtual Environment creation

  • In the top menu, click: Terminal 🡪 New Terminal
    • If you see the letters PS before the C:\Projects path, do:
      • Close the terminal (click the X on the upper-right corner of the terminal window)
      • Open the Command Palette: Ctrl+Shift+P
      • Type: Terminal: Select Default Profile
      • Choose: Command Prompt
      • Retry…
  • A command window will open at the bottom
  • You should see that the newly created virtual environment is active by its name presented before the path: (.venv) C:\Projects>

11

Motti Bazar, mottibz@gmail.com

12 of 16

Test Python in VSCode

  • Make sure the Explorer icon is active on the upper-left
  • Click the “New File” icon
  • Type “demo.py” and Enter
  • Type the print command on the right
  • Click the RUN button (upper-right �corner) to execute the Python script

  • A terminal will open at the bottom, and �the Python script will execute

12

Motti Bazar, mottibz@gmail.com

13 of 16

Installing common libraries

  • During our learning, we will utilize different libraries. To install them, open a terminal (Terminal 🡪 New Terminal), and type the command:

pip install numpy pandas matplotlib seaborn scikit-learn

  • Progress will be presented, and the libraries will be installed

13

Motti Bazar, mottibz@gmail.com

14 of 16

Why we use Notebooks

  • Why we’ll use notebooks in VSCode instead of plain Python files:
    • Run code in small steps – execute one cell at a time and see results instantly
    • Mix code, text, and visuals – perfect for explanations, formulas, and charts
    • Great for data science – view tables and plots right under the code
    • Keeps a record – code, explanations, and outputs all in one file
    • Easy to share – others can read and run it exactly as you wrote it
  • “A notebook is like a smart document for coding – code, explanations, and results together, making learning data science much easier”

14

Motti Bazar, mottibz@gmail.com

15 of 16

Adding Notebooks support to VSCode

  • Select the Extensions icon (as in slide #8)
  • Type “Jupyter” in the extensions search box and �install the Microsoft version

  • Complete adding the support:
    • Click the New File icon
    • Call the file “demo.ipynb” (make sure that you use the .ipynb file extension)
    • Click the “+ Code” icon at the top. A notebook cell will open
    • Type print(“hello”) in the cell
    • Click Control-Enter to execute the cell
    • If a dropdown will open, select the Python 3.12.10 venv option
    • If a window will pop up stating the need to install the ipykernel package, select Install. Install progress will be presented on the lower-right corner
    • When installation complete, execute the cell by clicking Control-Enter and “hello” will be printed below the cell

15

Motti Bazar, mottibz@gmail.com

16 of 16

Congratulations!

We are ready to code in Python!

16