0% found this document useful (0 votes)
4 views3 pages

Setting Up Python Using vs Code

This document provides a step-by-step guide for setting up Python and Visual Studio Code (VS Code) for artificial intelligence development. It includes instructions for installing Python, VS Code, the Python extension, configuring the interpreter, installing pip, creating a virtual environment, and running Python files. The guide is intended for students learning artificial intelligence under the instruction of Eng. Billy Peter Munyenyembe at Information and Communications University.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Setting Up Python Using vs Code

This document provides a step-by-step guide for setting up Python and Visual Studio Code (VS Code) for artificial intelligence development. It includes instructions for installing Python, VS Code, the Python extension, configuring the interpreter, installing pip, creating a virtual environment, and running Python files. The guide is intended for students learning artificial intelligence under the instruction of Eng. Billy Peter Munyenyembe at Information and Communications University.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Information and communications University

Artificial intelligence

Lecturer: Eng. Billy Peter Munyenyembe

Setting Up Python Using Visual Studio


Code (VS Code)
Install Python
1. Download and Install Python:
- Go to the official Python website: [Download
Python](https://www.python.org/downloads/).
- Download the latest version of Python.
- Run the installer and make sure to check the box that says "Add Python to PATH" before
clicking "Install Now."

Install Visual Studio Code (VS Code)


1. Download and Install VS Code:
- Go to the official VS Code website: [Download VS Code](https://code.visualstudio.com/).
- Download and install the appropriate version for your operating system.

Install the Python Extension for VS Code


1. Open VS Code:
- Launch VS Code after the installation is complete.

2. Install the Python Extension:


- Click on the Extensions view icon on the Sidebar (or press `Ctrl+Shift+X`).
- In the search bar, type `Python`.
- Select the Python extension by Microsoft and click "Install."

Configure Python in VS Code


1. Select the Python Interpreter:
- Press `Ctrl+Shift+P` to open the Command Palette.
- Type `Python: Select Interpreter` and select it.
- Choose the Python interpreter that you installed earlier (it will usually be something like
Information and communications University

Artificial intelligence

Lecturer: Eng. Billy Peter Munyenyembe

`Python 3.x.x`).

Install Pip
Pip is the package installer for Python. If you installed Python from python.org, pip should
already be installed.

1. Verify Pip Installation:


- Open a terminal or command prompt.
- Run the following command to check if pip is installed:
```bash
pip --version
```
- If pip is installed, you will see the version number. If not, you can install pip by following
the instructions on the [official pip website](https://pip.pypa.io/en/stable/installation/).

2. Upgrade Pip:
- It is a good practice to ensure that pip is up to date. Run the following command to
upgrade pip:
```bash
python -m pip install --upgrade pip
```

Set Up a Virtual Environment


1. Open a Terminal in VS Code:
- Open the terminal by selecting `Terminal` > `New Terminal` from the menu.

2. Create a Virtual Environment:


- Navigate to your project directory in the terminal.
- Run the following command to create a virtual environment:
```bash
python -m venv myenv
```

3. Activate the Virtual Environment


- Windows:
```bash
Information and communications University

Artificial intelligence

Lecturer: Eng. Billy Peter Munyenyembe

myenv\Scripts\activate
```
-macOS/Linux:
```bash
source myenv/bin/activate
```

4. Install Required Packages:


- With the virtual environment activated, you can now install any necessary Python
packages using `pip`. For example:
```bash
pip install numpy pandas matplotlib
```

Create and Run a Python File


1. Create a New Python File:
- In VS Code, create a new file by selecting `File` > `New File` or pressing `Ctrl+N`.
- Save the file with a `.py` extension, for example, `hello.py`.

2. Write and Run Python Code:


- Add some Python code to your file, for example:
```python
print("Hello, World!")
```
- Run the code by clicking the green play button in the top right corner of the editor, or by
right-clicking the file and selecting `Run Python File in Terminal.`

You might also like