Зміст курсу
Mastering Python: Annotations, Errors and Environment
Mastering Python: Annotations, Errors and Environment
Virtual 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.
Дякуємо за ваш відгук!