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
我的眼睛已经— —了。