云学编程的第17天—【微软官方python入门教程 P34笔记】2021-11-17虚拟环境Vitual environments

本文介绍如何使用Python的virtualenv工具来创建和管理独立的虚拟环境。这些环境可以帮助开发者隔离项目依赖,便于版本管理和团队协作。文章详细解释了在Windows、OSX及Linux系统中安装和激活虚拟环境的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

By default, packages are installed globlly

version management becoms a challenge

Virtual environments can be used to contain and manage package collections

Really just a folder behind the scenes with all your packages

 

Vitual environments is literally nothing but a folder, that has all of the code that you're going to need to run the application that you are creating, so everything I need is just going to be installed into that folder, and then I able to use them.

Install virtual environment

first, course a folder. use a utility called virtualenv, we will need to install that.the way that we do that is by saying pip install and then virtualenv,This one we want to do globally.

#Install virtual environment
pip install virtualenv

Then, the next step is to create that virtual environment.Just going to specify the name of the folder that I want to create. vene-virtual environment 

How you create that is going to vary slightly depending on the operating system that you're using.

windows-Python  -m stands for go grab a particular module

#Windows systems
python -m vent <folder_name>

OSX/Linux(bash) virtualenv

virtualenv <folder_name>
#bash 也可以使用python3 -m venv创建 ——来自热心弹幕

 Using virtual environments (activate it)

#Windows systems

#cmd.exe

<folder_name>\Scripts\Activate.bat

#Powershell

<folder_name>\Scripts\Activate.ps1

#bash shell

. ./<folder_name>/Scripts/activate

#OSX/Linux (bush)

<folder_name>/bin/activate

Installing packages in a virtual environment

#Install an individual package
pip install colorama#net requirements text file

#Install from a list of packages
pip install -r requirements.txt

#requirements.txt
colorama

我的眼睛已经— —了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值