Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Virtual Environment in IDE: VS Code | Virtual Environment
Mastering Python: Annotations, Errors and Environment
course content

Зміст курсу

Mastering Python: Annotations, Errors and Environment

Mastering Python: Annotations, Errors and Environment

1. Annotations
2. Function Arguments in Details
3. Error Handling
4. Virtual Environment

bookVirtual Environment in IDE: VS Code

There is another popular IDE - VS Code. Let's see how we can set up an interpreter using it.

Step 1. Open VS Code.
Open a new folder in VS Code and create the main.py file for a more convenient view.

You can see the interpreter tab in the bottom right corner, but clicking on it doesn't provide us with an interface for creating a virtual environment conveniently.

Step 2. Open New Terminal.

Step 3. Create a new Virtual Environment via Terminal.

Now VS Code recognizes the new environment and offers to connect to it. It's better to do it for comfortable use.

Step 4. Activate. VS Code automatically connects to this interpreter, so there is no need to activate the virtual environment every time the terminal is launched.

Virtual Environment in Terminal

Most likely, you are wondering, "Why do we need to activate a virtual environment in the terminal?".
The reason is that any program runs through the terminal. IDE offers us a simple launch in the form of the Run button, but in our system, the command python file.py (python3 file.py for Linux/MacOS) is executed. Any program works through the terminal, and when we learn more serious programs (for example, Backend built on Django), we will often have to use the terminal with a specific virtual environment.

Developers often use the terminal during development, so this knowledge is essential.

1. Try to create a virtual environment named "new_venv":
2. Try to activate the virtual environment named "new_venv":
question-icon

Try to create a virtual environment named "new_venv":

Натисніть або перетягніть елементи та заповніть пропуски

question-icon

Try to activate the virtual environment named "new_venv":

Windows:
new_venv\\activate

Linux:
//

Натисніть або перетягніть елементи та заповніть пропуски

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 5
some-alt