Install Python3 Virtual Environment (VIRTUALENV) on Mac
Objective
Before we get to the installation steps, let's talk about a few questions:
1. Why should I install a virtual machine?
A separate virtual environment allows each Python project to use an environment alone without affecting the Python system environment or the environment of other projects. As follows
The overall point is to be concise, do not introduce some unnecessary library
Second: Installation virtualenv environment
1: Installation
# or [sudo] pip3 install virtualenv [sudo]# available
2: Detection version
Virtualenv--version
Three: Using
1: Create a folder to hold the project and related virtual environment files.
such as creating files, Weblogindjango folders
2: In the terminal CD to the Weblogindjango folder path
3: Create a virtual environment
Virtualenv Weblogindjango or
Virtualenv Weblogindjango--python=python3.6 #选择不同版本的python or
Virtualenv--no-site-packages Weblogindjango--python=python3.6 #指定只需要一个干净的环境, not the original with the various third-party libraries
Created successfully.
Activating a virtual environment
Source/users/chenhuili/desktop/javastuend/weblogindjango/weblogindjango/bin/activate
Note that you need to go to the folder operation related script file, /users/chenhuili/desktop/javastuend/weblogindjango/weblogindjango/bin/
Activation instruction: Activate
After successful activation, in the virtual environment, all the command line before the operation has the name of the folder, for example, the activation is successful
4: Install the relevant library
such as installing the Django Library
PIP3 Install Django
5: Exiting the virtual environment
Deactivate
Python Virtual Environment (VIRTUALENV)