Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
What is Virtual Environment? | 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

book
What is Virtual Environment?

Python has a wide variety of modules that can be installed using the console command pip, and among them, there are many different versions of Python available.

Python versions may support different sets of tools, modules, development environments, etc. Having only one version of Python on a computer can cause many errors, for example, new versions of Python are not yet adapted to all the necessary modules, or conversely, there are no modules for a new version of Python.

To solve this problem, there is the concept of a virtual environment, which allows you to isolate the version of Python and the list of modules for a specific project.

Note

Virtual Environment (venv) is an isolated development environment that allows developers to create an independent Python runtime and module environment for each project. This helps to avoid conflicts between different project dependencies and allows for more efficient collaboration across different development teams.

The system interpreter is the interpreter that you install on your device (i.e., on your operating system: Windows, Linux, or MacOS). Commands in the terminal work through this interpreter if you do not have a virtual environment.

How venv works?

When you create a virtual environment, you are essentially copying your system interpreter into the project folder with no additional modules loaded via pip. This creates a completely new and independent interpreter, similar to adding another Python to your computer. Once this new interpreter is activated, the required modules for the project can be loaded.

In the image, you can see separate Python interpreters. The Python version was copied from the base (system) interpreter, but additional modules were not installed in all projects. The Web Backend Project cannot use modules such as numpy and pandas because they are not installed there, while the New Project is completely empty and copied only built-in modules and the system version of the interpreter (i.e., it looks like the Python that was in your system immediately after installation, without additional pip modules).

This is a simplified explanation of how virtual environments work. In practice, the process can be a bit more complex, but you should be able to handle it without issue.

What is virtual environment (venv)?

What is virtual environment (venv)?

Виберіть правильну відповідь

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

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

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

Секція 4. Розділ 1
We're sorry to hear that something went wrong. What happened?
some-alt