virtualenv Introduce
virtualenv application
virtualenv Introducevirtualenv Provides isolated for applications Python Running environment , It solves the problem of multi version conflict between different applications .
virtualenv Put the system Python Make a copy to virtualenv Environment , Command source venv/bin/activate Enter a virtualenv Environmental time ,virtualenv The relevant environment variables will be modified , Let the order python and pip All point to the current virtualenv Environmental Science .
install virtualenv
pip3 install virtualenv
Create project
mkdir myprojectcd myproject/
Create a new python Environmental Science
virtualenv --no-site-packages py_new# Parameters :--no-site-packages Already installed on the system Python All third-party packages in the environment will not be copied
New Python The environment is placed in the current directory py_new Catalog .
With py_new Environmental Science , It can be used source Enter the environment :
source py_new/bin/activate
pip All installed packages are installed to py_new In this environment , System Python The environment is not affected in any way
pip install pandas
Exit the current py_new Environmental Science
deactivate
after pip or python All in the system Python Execution in environment
Add :virtualenv establish “ Isolation ” Of Python Running environment
Windows install mkvirtualenv
pip install virtualenvpip install virtualenvwrapper
New virtual python Environmental Science :
1. establish python Project directory :
2. Create an independent Python Running environment , Name it redis:
virtualenv redis
3. Activate the environment :( or workon)
cd D:\05_python_virtualenv\redis\Scripts.\activate
Notice that the command prompt has changed , There is one (venv) Prefix , Indicates that the current environment is one called venv Of Python Environmental Science
4. Exit the current venv Environmental Science :deactivate
There is an error :virtualenv: error: unrecognized arguments: --no-site-packages
Use virtualenv --version, See version greater than 20, This parameter is the default , It can be cancelled –no-site-packages
virtualenvwrapper --helprmvirtualenv redis
stay win Computer environment variables - System variables : newly added :WORKON_HOME, by D:\05_python_virtualenv
This is about virtualenv Isolation Python This is where the article on environment is introduced , More about virtualenv Isolation Python Please search the previous articles of the software development network or continue to browse the relevant articles below. I hope you will support the software development network in the future !