Creating and using linux virtual environment venv and virtualenvwrapper

1 . Linux install python virtual learning environment 


virtual environment provides tools linux 
have pipenv virtualenv   

2 we demand that can run on a linux django2 run a django1. 


3 virtual environment installation of python. 
PIP3 install -i HTTPS: // pypi.tuna .tsinghua.edu.cn / virtualenv the Simple 



4 . create a virtual environment through the command 

virtualenv --no-Site-Packages Standard Package - Python = python3 venv1 # create a clean and isolated virtual environment, and to python3 for the body copy, called a virtual environment name venv1
     --no-the sum of site Packages Standard Package create a clean isolated virtual environment python
     - python = python3 designated interpreter for the python3 

5 . tell your virtual environment principle 

view the current path variable physical environment: 
[root @ wangdachui opt] # echo $ PATH
/ opt / python36 / bin /: / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / root / bin: / root / bin 

activate the virtual environment, again viewing environment variable source . / of an activate 
(venv1) [root @ wangdachui bin] # echo $ the PATH
 / opt / venv1 / bin: / opt / python36 / bin /: / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / root / bin: / root / bin 

6 . check for proper installation of the virtual environment 

(venv1) [root @ wangdachui bin] # Which python3
 / opt / venv1 / bin / python3 
(venv1) [root @ wangdachui bin] # 
(venv1) [the root @ wangdachui bin] # 
(venv1) [the root @ wangdachui bin] # Which PIP3
 / opt / venv1 / bin / PIP3 
(venv1) [the root @ wangdachui bin] # 
(venv1) [the root @ wangdachui bin] #  
(venv1) [root @ wangdachui bin] # PIP3 List
Package Penalty for Version
------- ---------- 
PIP         19.0 . 3  
setuptools 40.8 . 0  
Wheel       0.33 . 1 


7 . Exit the virtual environment, and then check python3 interpreter path 
to exit the command 
deactivate 




8 . Creating two virtual environmental venv1 venv2 are running Django 1 , Django   2 

    1 activation venv1 create django1.. 11.14 
    [root @ wangdachui opt] # Source venv1 / bin / of an activate
     2 installed Django. 
    PIP3 install -i HTTPS: // pypi.douban.com/simple 1.11.14 == Django 

    3  . create a project run django
    Django - ADMIN startproject mydjango114 
    
    
    4 . Creating venv2, create django2 version 
    virtualenv --no-Site-Packages Standard Package - Python = python3 venv2 
    
    activate venv2 
    Source venv2 / bin / of an activate 
    download django2 version, and create django2 project 
    PIP3 install -i HTTPS: // pypi.douban.com/simple django 
    create a project run django 
    django - ADMIN startproject mydjango21 
    


1 . virtual environment tools virtuelenv must find venv1 that folder
 2 and have to manually activate the source.

1. Install the python virtual environment
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple virtualenv

2. Create a virtual environment through the command

virtualenv --no-site-packages --python=python3 venv1

3. Activate the virtual environment

source venv1/bin/activate

4. Exit command virtual environment 

deactivate

Virtualenv virtualenvwrapper learning an upgraded version of the tool
     1 . Installation 
        PIP3 install virtualenvwrapper 
    2 . Configuration personal environment variable configuration file, each landing will start virtualenvwrapper tool 
        vim ~ / .bashrc 
     3 . Write load variables such virtualenvwrapper each boot can use 
        export WORKON_HOME ~ = / Envs that provided # virtualenv unified management directory 
        Export VIRTUALENVWRAPPER_VIRTUALENV_ARGS = ' --no-Site-Packages '   

        # virtualenvwrapper add parameters to generate a clean environment isolated 
        Export VIRTUALENVWRAPPER_PYTHON = / opt / python36 / bin / to python3 # specify the python interpreter 

        Source / opt / python36 / bin / virtualenvwrapper.sh # virtualenvwrapper execute the installation script
        
        
    4 Exit answer, logout, log back in to see if the tool is installed 
    
    5 . Virtualenvwrapper learning tool orders
         1 . Create a new virtual environment 
        mkvirtualenv MyCRM 
        
        2 . Switching multiple virtual environments 
        workon name of the virtual environment 
        
        3 . List all of the virtual environment directory 
        lsvirtualenv 
        
        4 . enter the directory currently active virtual environment 
        cdvirtualenv
    

 

Guess you like

Origin www.cnblogs.com/l1222514/p/11410241.html