Home  >  Article  >  Backend Development  >  Learn Python with AWS - Day 2

Learn Python with AWS - Day 2

王林
王林Original
2024-08-12 18:46:43752browse

Virtual Environments

Today we will learn about virtual environments. A virtual environment in python is a container in which all your code and other python packages reside. It allows you to keep your python configuration separate from other versions on your system. It is a good idea to always use a virtual environment when developing python code.

To create a virtual environment we will use the command:

python -m venv my_venv

Once the virtual environment has been created, you need to activate it. Once activated, your code runs inside the environment, including any packages you install. To activate the environment use one of the following commands:

Linus/mac OS:

source my_venv/bin/activate

Windows (Git-Bash):

source my_venv/Scripts/activate

To know you are inside the virtual environment your command prompt will have the prefix (my_venv). Now any packages you use will be stored in a folder structure inside your virtual environment.

To exit from the virtual environment, you type deactivate and the command prompt will no longer be prefixed by (my_venv).

Learn Python with AWS - Day 2

The above is the detailed content of Learn Python with AWS - Day 2. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn